mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LangBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
@@ -315,10 +317,7 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
PsiDocComment comment = getDocComment(aClass);
|
||||
if (comment != null) {
|
||||
generateDescription(buffer, comment);
|
||||
generateDeprecatedSection(buffer, comment);
|
||||
generateSinceSection(buffer, comment);
|
||||
generateSeeAlsoSection(buffer, comment);
|
||||
generateCommonSection(buffer, comment);
|
||||
generateTypeParametersSection(buffer, aClass);
|
||||
}
|
||||
generateEpilogue(buffer);
|
||||
@@ -418,10 +417,7 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
PsiDocComment comment = getDocComment(field);
|
||||
if (comment != null) {
|
||||
generateDescription(buffer, comment);
|
||||
generateDeprecatedSection(buffer, comment);
|
||||
generateSinceSection(buffer, comment);
|
||||
generateSeeAlsoSection(buffer, comment);
|
||||
generateCommonSection(buffer, comment);
|
||||
}
|
||||
|
||||
generateEpilogue(buffer);
|
||||
@@ -463,6 +459,23 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
private void generatePackageJavaDoc(final StringBuilder buffer, final PsiPackage psiPackage) {
|
||||
for(PsiDirectory directory: psiPackage.getDirectories()) {
|
||||
final PsiFile packageInfoFile = directory.findFile("package-info.java");
|
||||
if (packageInfoFile != null) {
|
||||
final ASTNode node = packageInfoFile.getNode();
|
||||
if (node != null) {
|
||||
final ASTNode docCommentNode = node.findChildByType(JavaDocElementType.DOC_COMMENT);
|
||||
if (docCommentNode != null) {
|
||||
final PsiDocComment docComment = (PsiDocComment)docCommentNode.getPsi();
|
||||
|
||||
generatePrologue(buffer);
|
||||
|
||||
generateCommonSection(buffer, docComment);
|
||||
|
||||
generateEpilogue(buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiFile packageHtmlFile = directory.findFile("package.html");
|
||||
if (packageHtmlFile != null) {
|
||||
generatePackageHtmlJavaDoc(buffer, packageHtmlFile);
|
||||
@@ -471,6 +484,13 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateCommonSection(StringBuilder buffer, PsiDocComment docComment) {
|
||||
generateDescription(buffer, docComment);
|
||||
generateDeprecatedSection(buffer, docComment);
|
||||
generateSinceSection(buffer, docComment);
|
||||
generateSeeAlsoSection(buffer, docComment);
|
||||
}
|
||||
|
||||
private void generatePackageHtmlJavaDoc(final StringBuilder buffer, final PsiFile packageHtmlFile) {
|
||||
String htmlText;
|
||||
XmlFile packageXmlFile = (XmlFile) packageHtmlFile;
|
||||
@@ -502,9 +522,7 @@ public class JavaDocInfoGenerator {
|
||||
|
||||
generatePrologue(buffer);
|
||||
|
||||
generateDescription(buffer, docComment);
|
||||
generateSinceSection(buffer, docComment);
|
||||
generateSeeAlsoSection(buffer, docComment);
|
||||
generateCommonSection(buffer, docComment);
|
||||
|
||||
generateEpilogue(buffer);
|
||||
}
|
||||
|
||||
+6
-4
@@ -40,15 +40,17 @@ public class WrongPackageStatementInspection extends BaseJavaLocalInspectionTool
|
||||
if (file instanceof PsiJavaFile) {
|
||||
if (JspPsiUtil.isInJspFile(file)) return null;
|
||||
PsiJavaFile javaFile = (PsiJavaFile)file;
|
||||
// highlight the first class in the file only
|
||||
PsiClass[] classes = javaFile.getClasses();
|
||||
if (classes.length == 0) return null;
|
||||
|
||||
PsiDirectory directory = javaFile.getContainingDirectory();
|
||||
if (directory == null) return null;
|
||||
PsiPackage dirPackage = JavaDirectoryService.getInstance().getPackage(directory);
|
||||
if (dirPackage == null) return null;
|
||||
PsiPackageStatement packageStatement = javaFile.getPackageStatement();
|
||||
|
||||
// highlight the first class in the file only
|
||||
PsiClass[] classes = javaFile.getClasses();
|
||||
if (classes.length == 0 && packageStatement == null) return null;
|
||||
|
||||
String packageName = dirPackage.getQualifiedName();
|
||||
if (!Comparing.strEqual(packageName, "", true) && packageStatement == null) {
|
||||
String description = JavaErrorMessages.message("missing.package.statement", packageName);
|
||||
@@ -75,7 +77,7 @@ public class WrongPackageStatementInspection extends BaseJavaLocalInspectionTool
|
||||
String description = JavaErrorMessages.message("package.name.file.path.mismatch",
|
||||
packageReference.getText(),
|
||||
dirPackage.getQualifiedName());
|
||||
return new ProblemDescriptor[]{manager.createProblemDescriptor(packageStatement, description, isOnTheFly, availableFixes.toArray(new LocalQuickFix[availableFixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
|
||||
return new ProblemDescriptor[]{manager.createProblemDescriptor(packageStatement.getPackageReference(), description, isOnTheFly, availableFixes.toArray(new LocalQuickFix[availableFixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class JavaRefactoringSettings implements PersistentStateComponent<JavaRef
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_INHERITORS = true;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_PARAMETER_IN_HIERARCHY = true;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_VARIABLES = true;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean RENAME_TESTS = true;
|
||||
|
||||
public static JavaRefactoringSettings getInstance() {
|
||||
return ServiceManager.getService(JavaRefactoringSettings.class);
|
||||
@@ -136,4 +137,12 @@ public class JavaRefactoringSettings implements PersistentStateComponent<JavaRef
|
||||
public void loadState(JavaRefactoringSettings state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
public boolean isToRenameTests() {
|
||||
return RENAME_TESTS;
|
||||
}
|
||||
|
||||
public void setRenameTests(boolean renameTests) {
|
||||
this.RENAME_TESTS = renameTests;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -35,10 +35,11 @@ public class ChangeSignatureTargetUtil {
|
||||
return PsiTreeUtil.getParentOfType(element, PsiMethod.class);
|
||||
}
|
||||
|
||||
final PsiMethodCallExpression expression = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
|
||||
final PsiCallExpression expression = PsiTreeUtil.getParentOfType(element, PsiCallExpression.class);
|
||||
if (expression != null) {
|
||||
assert element != null;
|
||||
final PsiExpression qualifierExpression = expression.getMethodExpression().getQualifierExpression();
|
||||
final PsiExpression qualifierExpression = expression instanceof PsiMethodCallExpression ? ((PsiMethodCallExpression)expression).getMethodExpression().getQualifierExpression()
|
||||
: expression instanceof PsiNewExpression ? ((PsiNewExpression)expression).getQualifier() : null;
|
||||
if (PsiTreeUtil.isAncestor(qualifierExpression, element, false)) {
|
||||
final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(qualifierExpression, PsiExpressionList.class);
|
||||
if (expressionList != null) {
|
||||
|
||||
@@ -110,6 +110,8 @@ public class ExtractClassProcessor extends FixableUsagesRefactoringProcessor {
|
||||
}
|
||||
for (PsiMethod method : methods) {
|
||||
method.accept(visitor);
|
||||
//do not include method's type parameters in class signature
|
||||
typeParamSet.removeAll(Arrays.asList(method.getTypeParameters()));
|
||||
}
|
||||
typeParams.addAll(typeParamSet);
|
||||
}
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.refactoring.rename.naming;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class AutomaticTestRenamerFactory implements AutomaticRenamerFactory {
|
||||
public boolean isApplicable(final PsiElement element) {
|
||||
return element instanceof PsiClass;
|
||||
}
|
||||
|
||||
public String getOptionName() {
|
||||
return RefactoringBundle.message("rename.tests");
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return JavaRefactoringSettings.getInstance().isToRenameTests();
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
JavaRefactoringSettings.getInstance().setRenameTests(enabled);
|
||||
}
|
||||
|
||||
public AutomaticRenamer createRenamer(final PsiElement element, final String newName, final Collection<UsageInfo> usages) {
|
||||
return new TestsRenamer((PsiClass)element, newName);
|
||||
}
|
||||
|
||||
private static class TestsRenamer extends AutomaticRenamer {
|
||||
public TestsRenamer(PsiClass aClass, String newClassName) {
|
||||
|
||||
appendTestClass(aClass, "Test");
|
||||
appendTestClass(aClass, "TestCase");
|
||||
|
||||
suggestAllNames(aClass.getName(), newClassName);
|
||||
}
|
||||
|
||||
private void appendTestClass(PsiClass aClass, String testSuffix) {
|
||||
final Project project = aClass.getProject();
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass psiClassTest = facade.findClass(aClass.getQualifiedName() + testSuffix, GlobalSearchScope.projectScope(project));
|
||||
if (psiClassTest != null) {
|
||||
myElements.add(psiClassTest);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDialogTitle() {
|
||||
return RefactoringBundle.message("rename.tests.title");
|
||||
}
|
||||
|
||||
public String getDialogDescription() {
|
||||
return RefactoringBundle.message("rename.tests.with.the.following.names.to");
|
||||
}
|
||||
|
||||
public String entityName() {
|
||||
return RefactoringBundle.message("entity.name.test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><PRE>class <b>MethodTypeParam</b><T>
|
||||
extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE>
|
||||
<DD><DL><DT><b>Type parameters:</b><DD><code><T></code> - type param</DD></DL></DD></body></html>
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @param <T> type param
|
||||
*/
|
||||
class MethodTypeParam<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><small><b><a href="psi_element://A"><code>A</code></a></b></small><PRE>public static int <b>JAVADOC_ME = 23</b></PRE> The value of the field is 23.</body></html>
|
||||
@@ -0,0 +1,4 @@
|
||||
class A {
|
||||
/** The value of the field is {@value}. */
|
||||
public static int JAVADOC_ME = 23;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><small><b><a href="psi_element://Idea4780"><code>Idea4780</code></a></b></small><PRE>public <a href="psi_element://java.lang.Object"><code>Object</code></a> <b>read</b>()
|
||||
throws <a href="psi_element://java.io.IOException"><code>IOException</code></a></PRE><DD><DL><DT><b>Throws:</b><DD><a href="psi_element://java.io.EOFException"><code>EOFException</code></a> - if this source is already closed when the <code>read()</code> is called, or is closed during the <code>read()</code>. <DD><font color=red>InterruptedIOException</font> - if the reading thread is interrupted.<DD><a href="psi_element://java.io.IOException"><code>IOException</code></a> - if an I/O error occurs while reading. </DD></DL></DD></body></html>
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.io.*;
|
||||
|
||||
public interface Idea4780 {
|
||||
/**
|
||||
* @throws IOException if an I/O error occurs while reading.
|
||||
* @throws EOFException if this source is already closed when the <code>read()</code> is called,
|
||||
* or is closed during the <code>read()</code>.
|
||||
* @throws InterruptedIOException if the reading thread is interrupted.
|
||||
*/
|
||||
public Object read()
|
||||
throws IOException;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><small><b><a href="psi_element://MethodTypeParam"><code>MethodTypeParam</code></a></b></small><PRE><T> void <b>foo</b>(T t)</PRE><DD><DL><DT><b>Type parameters:</b><DD><code><T></code> - type param</DD></DL></DD></body></html>
|
||||
@@ -0,0 +1,7 @@
|
||||
class MethodTypeParam {
|
||||
/**
|
||||
* @param <T> type param
|
||||
*/
|
||||
<T> void foo(T t) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains nothing but package-info.java
|
||||
*/
|
||||
package packageInfo;
|
||||
@@ -0,0 +1,2 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body>
|
||||
This package contains nothing but package-info.java</body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><small><b><a href="psi_element://A"><code>A</code></a></b></small><PRE>public static int <b>JAVADOC_ME</b></PRE> Test</body></html>
|
||||
@@ -0,0 +1,4 @@
|
||||
class A {
|
||||
/** Test */
|
||||
public static int JAVADOC_ME;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } </style></head><body><small><b><a href="psi_element://A"><code>A</code></a></b></small><PRE>public static void <b>JAVADOC_ME</b>()</PRE> The value of A is 23.</body></html>
|
||||
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
public static int A = 23;
|
||||
|
||||
/** The value of A is {@value #A}. */
|
||||
public static void JAVADOC_ME() { }
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import java.util.*;
|
||||
class A1<T> {
|
||||
A1(){}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Callable<Object> callable = new Callable<Object>() {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class Extracted {
|
||||
public Extracted() {
|
||||
}
|
||||
|
||||
public <T> void foo(T p) {
|
||||
System.out.println(p.getClass().getName());
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
private final Extracted extracted = new Extracted();
|
||||
|
||||
public <T> void foo(T p) {
|
||||
extracted.foo(p);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test().foo(10f);
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
public <T> void foo(T p) {
|
||||
System.out.println(p.getClass().getName());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test().foo(10f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -227,6 +227,10 @@ public class ExtractClassTest extends MultiFileTestCase{
|
||||
doTestField(null);
|
||||
}
|
||||
|
||||
public void testMethodTypeParameters() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
public void testPublicVisibility() throws Exception {
|
||||
doTest(new PerformAction() {
|
||||
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,7 +43,7 @@ import java.util.Set;
|
||||
* @author peter
|
||||
*/
|
||||
public class FileContentUtil {
|
||||
public static final String FORCE_RELOAD_REQUESTOR = "FileContentUtil.saveOrReload";
|
||||
@NonNls public static final String FORCE_RELOAD_REQUESTOR = "FileContentUtil.saveOrReload";
|
||||
|
||||
private FileContentUtil() {
|
||||
}
|
||||
@@ -67,23 +68,23 @@ public class FileContentUtil {
|
||||
}
|
||||
|
||||
public static void reparseFiles(@NotNull final Project project, @NotNull final Collection<VirtualFile> files, boolean includeOpenFiles) {
|
||||
final Set<VFilePropertyChangeEvent> list = new THashSet<VFilePropertyChangeEvent>();
|
||||
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
|
||||
for (VirtualFile file : files) {
|
||||
saveOrReload(file, list);
|
||||
saveOrReload(file, events);
|
||||
}
|
||||
if (includeOpenFiles) {
|
||||
for (VirtualFile open : FileEditorManager.getInstance(project).getOpenFiles()) {
|
||||
if (!files.contains(open)) {
|
||||
saveOrReload(open, list);
|
||||
saveOrReload(open, events);
|
||||
}
|
||||
}
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
|
||||
.before(new ArrayList<VFileEvent>(list));
|
||||
.before(new ArrayList<VFileEvent>(events));
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
|
||||
.after(new ArrayList<VFileEvent>(list));
|
||||
.after(new ArrayList<VFileEvent>(events));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ import com.intellij.lang.ASTFactory;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -248,4 +250,22 @@ public class FormatterUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isPrecededBy(ASTNode node, IElementType eType) {
|
||||
ASTNode prevNode = node.getTreePrev();
|
||||
while (prevNode != null && prevNode.getPsi() instanceof PsiWhiteSpace) {
|
||||
prevNode = prevNode.getTreePrev();
|
||||
}
|
||||
if (prevNode == null) return false;
|
||||
return prevNode.getElementType() == eType;
|
||||
}
|
||||
|
||||
public static boolean isPrecededBy(ASTNode node, TokenSet tokens) {
|
||||
ASTNode prevNode = node.getTreePrev();
|
||||
while (prevNode != null && prevNode.getPsi() instanceof PsiWhiteSpace) {
|
||||
prevNode = prevNode.getTreePrev();
|
||||
}
|
||||
if (prevNode == null) return false;
|
||||
return tokens.contains(prevNode.getElementType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.psi.formatter;
|
||||
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.formatting.WrapType;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* Misc. code wrapping functions
|
||||
* @author rvishnyakov
|
||||
*/
|
||||
public class WrappingUtil {
|
||||
|
||||
private WrappingUtil() {
|
||||
}
|
||||
|
||||
public static boolean shouldWrap(int setting) {
|
||||
return setting != CodeStyleSettings.DO_NOT_WRAP;
|
||||
}
|
||||
|
||||
public static Wrap createWrap(int setting) {
|
||||
return Wrap.createWrap(getWrapType(setting), true);
|
||||
}
|
||||
|
||||
public static WrapType getWrapType(int setting) {
|
||||
switch (setting) {
|
||||
case CodeStyleSettings.WRAP_ALWAYS:
|
||||
return WrapType.ALWAYS;
|
||||
case CodeStyleSettings.WRAP_AS_NEEDED:
|
||||
return WrapType.NORMAL;
|
||||
case CodeStyleSettings.DO_NOT_WRAP:
|
||||
return WrapType.NONE;
|
||||
default:
|
||||
return WrapType.CHOP_DOWN_IF_LONG;
|
||||
}
|
||||
}
|
||||
|
||||
public static WrapType getArrayInitializerWrapType(CodeStyleSettings settings,
|
||||
ASTNode node,
|
||||
IElementType lBraceType,
|
||||
IElementType rBraceType) {
|
||||
WrapType wrapType = WrapType.NONE;
|
||||
if (shouldWrap(settings.ARRAY_INITIALIZER_WRAP)) {
|
||||
if (node.getElementType() == rBraceType) {
|
||||
wrapType = settings.ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE ? Wrap.ALWAYS : Wrap.NONE;
|
||||
}
|
||||
else if (FormatterUtil.isPrecededBy(node, lBraceType)) {
|
||||
wrapType = settings.ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE ? Wrap.ALWAYS : Wrap.NONE;
|
||||
}
|
||||
else {
|
||||
wrapType = WrappingUtil.getWrapType(settings.ARRAY_INITIALIZER_WRAP);
|
||||
}
|
||||
}
|
||||
return wrapType;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ChangeList {
|
||||
}
|
||||
|
||||
private void flushChanges(boolean force) {
|
||||
if (myChangeSetDepth > 0) return;
|
||||
if (myChangeSetDepth > 0) return;
|
||||
if (myCurrentBlock.shouldFlush(force) || flushEveryChangeSetInTests()) {
|
||||
myStorage.writeNextBlock(myCurrentBlock);
|
||||
myCurrentBlock = myStorage.createNewBlock();
|
||||
|
||||
@@ -140,7 +140,7 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
}
|
||||
|
||||
public synchronized List<ChangeSetBlock> purge(long period, int intervalBetweenActivities) {
|
||||
List<ChangeSetBlock> result = new ArrayList<ChangeSetBlock>();
|
||||
List<ChangeSetBlock> result = new ArrayList<ChangeSetBlock>(); // todo : do not collect changesets
|
||||
int each = findFirstObsoleteBlock(period, intervalBetweenActivities);
|
||||
try {
|
||||
while(each != 0) {
|
||||
@@ -155,7 +155,6 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private int findFirstObsoleteBlock(long period, int intervalBetweenActivities) {
|
||||
long prevTimestamp = 0;
|
||||
long length = 0;
|
||||
@@ -178,8 +177,7 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public void flush() {
|
||||
public synchronized void flush() {
|
||||
myStorage.flushSome();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class LinkedRecordsTable extends AbstractRecordsTable {
|
||||
private static final int VERSION = 3;
|
||||
private static final int VERSION = 4;
|
||||
|
||||
private static final int ID_COUNTER_OFFSET = DEFAULT_HEADER_SIZE;
|
||||
private static final int FIRST_RECORD_OFFSET = ID_COUNTER_OFFSET + 8;
|
||||
@@ -62,6 +62,13 @@ public class LinkedRecordsTable extends AbstractRecordsTable {
|
||||
return ZEROS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearDeletedRecord(int record) {
|
||||
setTimestamp(record, 0);
|
||||
setNextRecord(record, 0);
|
||||
setPrevRecord(record, 0);
|
||||
}
|
||||
|
||||
public void setFSTimestamp(long timestamp) {
|
||||
markDirty();
|
||||
myStorage.putLong(FS_TIMESTAMP_OFFSET, timestamp);
|
||||
@@ -77,7 +84,6 @@ public class LinkedRecordsTable extends AbstractRecordsTable {
|
||||
}
|
||||
|
||||
public int getFirstRecord() {
|
||||
markDirty();
|
||||
return myStorage.getInt(FIRST_RECORD_OFFSET);
|
||||
}
|
||||
|
||||
@@ -87,7 +93,6 @@ public class LinkedRecordsTable extends AbstractRecordsTable {
|
||||
}
|
||||
|
||||
public int getLastRecord() {
|
||||
markDirty();
|
||||
return myStorage.getInt(LAST_RECORD_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,12 @@ public class LinkedStorage extends AbstractStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public int getFirstRecord() {
|
||||
synchronized (myLock) {
|
||||
return ((LinkedRecordsTable)myRecordsTable).getFirstRecord();
|
||||
}
|
||||
}
|
||||
|
||||
public int getLastRecord() {
|
||||
synchronized (myLock) {
|
||||
return ((LinkedRecordsTable)myRecordsTable).getLastRecord();
|
||||
@@ -67,6 +73,12 @@ public class LinkedStorage extends AbstractStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextRecord(int record) {
|
||||
synchronized (myLock) {
|
||||
return ((LinkedRecordsTable)myRecordsTable).getNextRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
public long getTimestamp(int record) {
|
||||
synchronized (myLock) {
|
||||
return ((LinkedRecordsTable)myRecordsTable).getTimestamp(record);
|
||||
|
||||
@@ -52,8 +52,8 @@ public class StreamUtil {
|
||||
}
|
||||
|
||||
public static Change readChange(DataInput in) throws IOException {
|
||||
switch (in.readInt()) {
|
||||
case 0:
|
||||
int type = in.readInt();
|
||||
switch (type) {
|
||||
case 1:
|
||||
return new CreateFileChange(in);
|
||||
case 2:
|
||||
@@ -73,14 +73,13 @@ public class StreamUtil {
|
||||
case 9:
|
||||
return new PutSystemLabelChange(in);
|
||||
}
|
||||
throw new IOException();
|
||||
throw new IOException("unexpected change type: " + type);
|
||||
}
|
||||
|
||||
public static void writeChange(DataOutput out, Change change) throws IOException {
|
||||
int id = -1;
|
||||
|
||||
Class c = change.getClass();
|
||||
if (c.equals(ChangeSet.class)) id = 0;
|
||||
if (c.equals(CreateFileChange.class)) id = 1;
|
||||
if (c.equals(CreateDirectoryChange.class)) id = 2;
|
||||
if (c.equals(ContentChange.class)) id = 3;
|
||||
@@ -91,7 +90,7 @@ public class StreamUtil {
|
||||
if (c.equals(PutLabelChange.class)) id = 8;
|
||||
if (c.equals(PutSystemLabelChange.class)) id = 9;
|
||||
|
||||
assert id != -1;
|
||||
if (id == -1) throw new IOException("unexpected change type: " + c);
|
||||
|
||||
out.writeInt(id);
|
||||
change.write(out);
|
||||
|
||||
-1
@@ -81,7 +81,6 @@ public class DirectoryHistoryDialog extends HistoryDialog<DirectoryHistoryDialog
|
||||
p.add(myToolBar.getComponent(), BorderLayout.NORTH);
|
||||
|
||||
p.add(myChangesTree, BorderLayout.CENTER);
|
||||
p.add(new DiffStatusBar(DiffStatusBar.DEFAULT_TYPES), BorderLayout.SOUTH);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.historyIntegrTests;
|
||||
|
||||
import com.intellij.history.core.LinkedStorage;
|
||||
import com.intellij.util.io.storage.AbstractStorage;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class LinkedStorageTest extends IntegrationTestCase {
|
||||
private LinkedStorage myStorage;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myStorage = new LinkedStorage(myRoot.getPath() + "/storage");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myStorage.dispose();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testBasic() throws Exception {
|
||||
assertFirstAndLast(0, 0);
|
||||
|
||||
int r1 = createRecord();
|
||||
int r2 = createRecord();
|
||||
|
||||
assertFirstAndLast(r1, r2);
|
||||
assertRecord(r2, r1, 0);
|
||||
assertRecord(r1, 0, r2);
|
||||
}
|
||||
|
||||
public void testDeletion() throws Exception {
|
||||
int r1 = createRecord();
|
||||
int r2 = createRecord();
|
||||
int r3 = createRecord();
|
||||
|
||||
assertFirstAndLast(r1, r3);
|
||||
assertRecord(r3, r2, 0);
|
||||
assertRecord(r2, r1, r3);
|
||||
assertRecord(r1, 0, r2);
|
||||
|
||||
myStorage.deleteRecord(r2);
|
||||
|
||||
assertFirstAndLast(r1, r3);
|
||||
assertRecord(r3, r1, 0);
|
||||
assertRecord(r1, 0, r3);
|
||||
|
||||
myStorage.deleteRecord(r3);
|
||||
|
||||
assertFirstAndLast(r1, r1);
|
||||
assertRecord(r1, 0, 0);
|
||||
|
||||
int r4 = createRecord();
|
||||
|
||||
assertFirstAndLast(r1, r4);
|
||||
assertRecord(r4, r1, 0);
|
||||
assertRecord(r1, 0, r4);
|
||||
|
||||
myStorage.deleteRecord(r1);
|
||||
|
||||
assertFirstAndLast(r4, r4);
|
||||
assertRecord(r4, 0, 0);
|
||||
|
||||
myStorage.deleteRecord(r4);
|
||||
|
||||
assertFirstAndLast(0, 0);
|
||||
}
|
||||
|
||||
public void testReopening() throws Exception {
|
||||
int r1 = createRecord();
|
||||
int r2 = createRecord();
|
||||
int r3 = createRecord();
|
||||
|
||||
myStorage.deleteRecord(r2);
|
||||
|
||||
myStorage.dispose();
|
||||
myStorage = new LinkedStorage(myRoot.getPath() + "/storage");
|
||||
|
||||
assertFirstAndLast(r1, r3);
|
||||
assertRecord(r3, r1, 0);
|
||||
assertRecord(r1, 0, r3);
|
||||
|
||||
myStorage.deleteRecord(r1);
|
||||
|
||||
myStorage.dispose();
|
||||
myStorage = new LinkedStorage(myRoot.getPath() + "/storage");
|
||||
|
||||
assertFirstAndLast(r3, r3);
|
||||
assertRecord(r3, 0, 0);
|
||||
|
||||
int r4 = createRecord();
|
||||
|
||||
myStorage.dispose();
|
||||
myStorage = new LinkedStorage(myRoot.getPath() + "/storage");
|
||||
|
||||
assertFirstAndLast(r3, r4);
|
||||
assertRecord(r4, r3, 0);
|
||||
assertRecord(r3, 0, r4);
|
||||
}
|
||||
|
||||
private int createRecord() throws IOException {
|
||||
int r = myStorage.createNextRecord();
|
||||
AbstractStorage.StorageDataOutput s = myStorage.writeStream(r);
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
s.writeInt(r);
|
||||
}
|
||||
s.close();
|
||||
return r;
|
||||
}
|
||||
|
||||
private void assertFirstAndLast(int first, int last) {
|
||||
assertEquals(first, myStorage.getFirstRecord());
|
||||
assertEquals(last, myStorage.getLastRecord());
|
||||
}
|
||||
|
||||
private void assertRecord(int id, int prev, int next) throws IOException {
|
||||
assertEquals(prev, myStorage.getPrevRecord(id));
|
||||
assertEquals(next, myStorage.getNextRecord(id));
|
||||
DataInputStream s = myStorage.readStream(id);
|
||||
try {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
assertEquals(id, s.readInt());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author oleg
|
||||
* @author Roman.Chernyatchik, oleg
|
||||
*/
|
||||
public interface CommandLineArgumentsProvider {
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
|
||||
import com.intellij.util.Icons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -36,6 +37,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a file in <code>{@link VirtualFileSystem}</code>. A particular file is represented by the same
|
||||
@@ -451,7 +453,10 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
|
||||
if (isValid() && !application.isDisposed()) {
|
||||
application.runWriteAction(new Runnable(){
|
||||
public void run() {
|
||||
application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES).after(Collections.singletonList(new VFilePropertyChangeEvent(this, VirtualFile.this, PROP_ENCODING, old, charset, false)));
|
||||
List<VFilePropertyChangeEvent> events = Collections.singletonList(new VFilePropertyChangeEvent(this, VirtualFile.this, PROP_ENCODING, old, charset, false));
|
||||
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
|
||||
listener.before(events);
|
||||
listener.after(events);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.CharFilter;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -50,6 +51,11 @@ public class GuiUtils {
|
||||
private static final Insets paddingInsideDialog = new Insets(5, 5, 5, 5);
|
||||
|
||||
public static final int lengthForFileField = 25;
|
||||
private static final CharFilter NOT_MNEMONIC_CHAR_FILTER = new CharFilter() {
|
||||
public boolean accept(char ch) {
|
||||
return ch != '&' && ch != UIUtil.MNEMONIC;
|
||||
}
|
||||
};
|
||||
|
||||
public static JPanel constructFieldWithBrowseButton(JComponent aComponent, ActionListener aActionListener) {
|
||||
return constructFieldWithBrowseButton(aComponent, aActionListener, 0);
|
||||
@@ -187,7 +193,7 @@ public class GuiUtils {
|
||||
}
|
||||
|
||||
public static String getTextWithoutMnemonicEscaping(String text) {
|
||||
return text.replaceAll("&", "");
|
||||
return StringUtil.strip(text, NOT_MNEMONIC_CHAR_FILTER);
|
||||
}
|
||||
|
||||
public static char getDisplayedMnemonic(String text) {
|
||||
|
||||
+6
-1
@@ -110,6 +110,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
connection.subscribe(StateStorage.STORAGE_TOPIC, new StateStorage.Listener() {
|
||||
public void storageFileChanged(final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
VirtualFile file = event.getFile();
|
||||
LOG.info("[RELOAD] Storage file changed: " + file.getPath());
|
||||
if (!file.isDirectory() && !(event.getRequestor() instanceof StateStorage.SaveSession)) {
|
||||
saveChangedProjectFile(file, null, storage);
|
||||
}
|
||||
@@ -535,6 +536,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}
|
||||
|
||||
private void askToReloadProjectIfConfigFilesChangedExternally() {
|
||||
LOG.info("[RELOAD] myReloadBlockCount = " + myReloadBlockCount.get());
|
||||
if (myReloadBlockCount.get() == 0) {
|
||||
Set<Project> projects;
|
||||
|
||||
@@ -572,7 +574,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
reloadOk[0] = ((ApplicationImpl)app).getStateStore().reload(causes, components);
|
||||
}
|
||||
catch (StateStorage.StateStorageException e) {
|
||||
@@ -639,6 +640,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
LOG.info("[RELOAD] Reloading project/components...");
|
||||
reloadOk[0] = ((ProjectEx)project).getStateStore().reload(causes);
|
||||
}
|
||||
catch (StateStorage.StateStorageException e) {
|
||||
@@ -725,6 +727,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}
|
||||
|
||||
private void registerProjectToReload(final Project project, final VirtualFile cause, final StateStorage storage) {
|
||||
LOG.info("[RELOAD] Registering project to reload.");
|
||||
|
||||
if (project != null) {
|
||||
synchronized (myChangedProjectFiles) {
|
||||
List<Pair<VirtualFile, StateStorage>> changedProjectFiles = myChangedProjectFiles.get(project);
|
||||
@@ -743,6 +747,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
myChangedFilesAlarm.cancelAllRequests();
|
||||
myChangedFilesAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
LOG.info("[RELOAD] Scheduling reload application & project, myReloadBlockCount = " + myReloadBlockCount);
|
||||
if (myReloadBlockCount.get() == 0) {
|
||||
scheduleReloadApplicationAndProject();
|
||||
}
|
||||
|
||||
@@ -562,6 +562,7 @@ automatic.renamer.rename.to.column=Rename To
|
||||
rename.0.and.its.usages.to=Rename {0} and its usages to:
|
||||
rename.variables=Rename &variables
|
||||
rename.inheritors=Rename &inheritors
|
||||
rename.tests=Rename &tests
|
||||
rename.parameters.hierarchy=Rename parameters in hier&archy
|
||||
rename.bound.forms=Rename bound &forms
|
||||
inner.class.0.is.already.defined.in.class.1=Inner class {0} is already defined in class {1}.\nContinue anyway?
|
||||
@@ -577,8 +578,11 @@ rename.bound.forms.title=Rename bound forms
|
||||
rename.forms.with.the.following.names.to=Rename forms with the following names to:
|
||||
entity.name.form=Form
|
||||
rename.inheritors.title=Rename Inheritors
|
||||
rename.tests.title=Rename Tests
|
||||
rename.inheritors.with.the.following.names.to=Rename inheritors with the following names to:
|
||||
rename.tests.with.the.following.names.to=Rename tests with the following names to:
|
||||
entity.name.inheritor=Inheritor
|
||||
entity.name.test=Test
|
||||
unused.overriding.methods.title=Unused Overriding Methods
|
||||
there.are.unused.methods.that.override.methods.you.delete=There are unused methods that override methods you delete.
|
||||
choose.the.ones.you.want.to.be.deleted=Choose the ones you want to be deleted.
|
||||
|
||||
@@ -22,19 +22,13 @@
|
||||
<keyboard-shortcut first-keystroke="shift alt C" />
|
||||
</action>
|
||||
<action id="CheckinProject" />
|
||||
<action id="CloseActiveTab">
|
||||
<keyboard-shortcut first-keystroke="control F4" />
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
</action>
|
||||
<action id="CloseActiveTab" />
|
||||
<action id="CloseAllEditors">
|
||||
<keyboard-shortcut first-keystroke="shift control F4" />
|
||||
<keyboard-shortcut first-keystroke="shift control W" />
|
||||
</action>
|
||||
<action id="CloseEditor" />
|
||||
<action id="CloseWindow">
|
||||
<keyboard-shortcut first-keystroke="control F4" />
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
</action>
|
||||
<action id="CloseWindow" />
|
||||
<action id="CodeInspection.OnEditor" />
|
||||
<action id="CollapseAllRegions">
|
||||
<keyboard-shortcut first-keystroke="shift control DIVIDE" />
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
<keyboard-shortcut first-keystroke="UP"/>
|
||||
<keyboard-shortcut first-keystroke="control P"/>
|
||||
</action>
|
||||
<action id="CloseEditor">
|
||||
<action id="CloseContent">
|
||||
<keyboard-shortcut first-keystroke="control F4"/>
|
||||
<keyboard-shortcut first-keystroke="control X" second-keystroke="K"/>
|
||||
</action>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<action id="CloseActiveTab">
|
||||
<keyboard-shortcut first-keystroke="shift control 4" />
|
||||
</action>
|
||||
<action id="CloseEditor">
|
||||
<action id="CloseContent">
|
||||
<keyboard-shortcut first-keystroke="control 4" />
|
||||
</action>
|
||||
<action id="CompileDirty">
|
||||
|
||||
@@ -42,20 +42,16 @@
|
||||
<keyboard-shortcut first-keystroke="control alt BACK_SLASH" />
|
||||
</action>
|
||||
<action id="CloneElement" />
|
||||
<action id="CloseActiveTab">
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
</action>
|
||||
<action id="CloseActiveTab" />
|
||||
<action id="CloseAllEditors">
|
||||
<keyboard-shortcut first-keystroke="shift control W" />
|
||||
<keyboard-shortcut first-keystroke="shift control F4" />
|
||||
</action>
|
||||
<action id="CloseEditor">
|
||||
<action id="CloseContent">
|
||||
<keyboard-shortcut first-keystroke="control F4" />
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
</action>
|
||||
<action id="CloseWindow">
|
||||
<keyboard-shortcut first-keystroke="control W" />
|
||||
</action>
|
||||
<action id="CloseWindow" />
|
||||
<action id="CodeCompletion">
|
||||
<keyboard-shortcut first-keystroke="control SPACE" />
|
||||
<keyboard-shortcut first-keystroke="control BACK_SLASH" />
|
||||
|
||||
@@ -173,9 +173,12 @@ public abstract class AbstractRecordsTable implements Disposable, Forceable {
|
||||
public void deleteRecord(final int record) {
|
||||
ensureFreeRecordsScanned();
|
||||
setSize(record, -1);
|
||||
clearDeletedRecord(record);
|
||||
myFreeRecordsList.add(record);
|
||||
}
|
||||
|
||||
protected abstract void clearDeletedRecord(int record);
|
||||
|
||||
public int getVersion() {
|
||||
return myStorage.getInt(HEADER_VERSION_OFFSET);
|
||||
}
|
||||
|
||||
@@ -47,4 +47,8 @@ class RecordsTable extends AbstractRecordsTable {
|
||||
protected byte[] getZeros() {
|
||||
return ZEROES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearDeletedRecord(int record) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ class RefCountingRecordsTable extends AbstractRecordsTable {
|
||||
return ZEROES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearDeletedRecord(int record) {
|
||||
myStorage.putInt(getOffset(record, REF_COUNT_OFFSET), 0);
|
||||
}
|
||||
|
||||
public void incRefCount(int record) {
|
||||
markDirty();
|
||||
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.xdebugger.frame;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ImmediateFullValueEvaluator extends XFullValueEvaluator {
|
||||
private String myFullValue;
|
||||
|
||||
public ImmediateFullValueEvaluator(@NotNull String linkText, @NotNull String fullValue) {
|
||||
super(linkText);
|
||||
myFullValue = fullValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startEvaluation(@NotNull XFullValueEvaluationCallback callback) {
|
||||
callback.evaluated(myFullValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.xdebugger.frame;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Supports asynchronous fetching full text of a value. If full text is already computed use {@link ImmediateFullValueEvaluator}
|
||||
* @see XValueNode#setFullValueEvaluator
|
||||
* @see ImmediateFullValueEvaluator
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class XFullValueEvaluator {
|
||||
private String myLinkText;
|
||||
|
||||
/**
|
||||
* @param linkText text of the link what will be appended to a variables tree node text
|
||||
*/
|
||||
protected XFullValueEvaluator(@NotNull String linkText) {
|
||||
myLinkText = linkText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start fetching full text of the value. Note that this method is called from the Event Dispatch Thread so it should return quickly
|
||||
* @param callback used to notify that the full text has been successfully evaluated or an error occurs
|
||||
*/
|
||||
public abstract void startEvaluation(@NotNull XFullValueEvaluationCallback callback);
|
||||
|
||||
public String getLinkText() {
|
||||
return myLinkText;
|
||||
}
|
||||
|
||||
public interface XFullValueEvaluationCallback {
|
||||
void evaluated(@NotNull String fullValue);
|
||||
|
||||
void errorOccurred(@NotNull String errorMessage);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class XValueModifier {
|
||||
|
||||
/**
|
||||
* Start modification of the value. Note that this methods is called from the Event Dispatch Thread so it should return quickly
|
||||
* Start modification of the value. Note that this method is called from the Event Dispatch Thread so it should return quickly
|
||||
* @param expression new value
|
||||
* @param callback used to notify that value has been successfully modified or an error occurs
|
||||
*/
|
||||
|
||||
@@ -38,9 +38,8 @@ public interface XValueNode extends Obsolescent {
|
||||
/**
|
||||
* If string representation of the value is too long to show in the tree pass truncated value to {@link #setPresentation(String, javax.swing.Icon, String, String, boolean)}
|
||||
* method and call this method to provide full value.
|
||||
* This will add a link to the node and show <code>fullValue</code> text if a user click on that link.
|
||||
* @param fullValue full text of the value. Will be shown in popup window
|
||||
* @param linkText text of the link. Will be appended to the node text
|
||||
* This will add a link to the node and show popup with full value if an user clicks on that link.
|
||||
* @param fullValueEvaluator will be used to obtain full text of the value
|
||||
*/
|
||||
void setFullValue(@NotNull String fullValue, @NotNull String linkText);
|
||||
void setFullValueEvaluator(@NotNull XFullValueEvaluator fullValueEvaluator);
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerUtil;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
import com.intellij.xdebugger.frame.XFullValueEvaluator;
|
||||
import com.intellij.xdebugger.frame.XValue;
|
||||
import com.intellij.xdebugger.frame.XValueNode;
|
||||
import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint;
|
||||
@@ -90,7 +91,7 @@ public class XValueHint extends AbstractValueHint {
|
||||
});
|
||||
}
|
||||
|
||||
public void setFullValue(@NotNull String fullValue, @NotNull String linkText) {
|
||||
public void setFullValueEvaluator(@NotNull XFullValueEvaluator fullValueEvaluator) {
|
||||
//todo[nik] implement?
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.xdebugger.frame.XFullValueEvaluator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -90,26 +91,51 @@ public class DebuggerUIUtil {
|
||||
return new RelativePoint(editor.getContentComponent(), p);
|
||||
}
|
||||
|
||||
public static void showValuePopup(@NotNull String text, @NotNull MouseEvent event, @NotNull Project project) {
|
||||
JTextArea textArea = new JTextArea(text);
|
||||
public static void showValuePopup(@NotNull XFullValueEvaluator text, @NotNull MouseEvent event, @NotNull Project project) {
|
||||
final JTextArea textArea = new JTextArea("Evaluating...");
|
||||
text.startEvaluation(new FullValueEvaluationCallbackImpl(textArea));
|
||||
|
||||
textArea.setEditable(false);
|
||||
textArea.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
textArea.setLineWrap(false);
|
||||
final JScrollPane component = ScrollPaneFactory.createScrollPane(textArea);
|
||||
final Dimension frameSize = WindowManager.getInstance().getFrame(project).getSize();
|
||||
final Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
|
||||
component.setPreferredSize(size);
|
||||
component.setBorder(null);
|
||||
final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, null)
|
||||
.setResizable(true)
|
||||
.setMovable(true)
|
||||
.setDimensionServiceKey(project, "XDebugger.FullValuePopup", false)
|
||||
.setRequestFocus(false)
|
||||
.createPopup();
|
||||
|
||||
final Dimension size = textArea.getPreferredSize();
|
||||
final Component parentComponent = event.getComponent();
|
||||
final Dimension frameSize = WindowManager.getInstance().getFrame(project).getSize();
|
||||
size.width = Math.min(size.width, frameSize.width / 2);
|
||||
size.height = Math.min(size.height, frameSize.height / 2);
|
||||
component.setPreferredSize(size);
|
||||
RelativePoint point = new RelativePoint(parentComponent, new Point(event.getX()-size.width, event.getY()-size.height));
|
||||
popup.show(point);
|
||||
}
|
||||
|
||||
private static class FullValueEvaluationCallbackImpl implements XFullValueEvaluator.XFullValueEvaluationCallback {
|
||||
private final JTextArea myTextArea;
|
||||
|
||||
public FullValueEvaluationCallbackImpl(JTextArea textArea) {
|
||||
myTextArea = textArea;
|
||||
}
|
||||
|
||||
public void evaluated(@NotNull final String fullValue) {
|
||||
invokeOnEventDispatch(new Runnable() {
|
||||
public void run() {
|
||||
myTextArea.setText(fullValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void errorOccurred(@NotNull final String errorMessage) {
|
||||
invokeOnEventDispatch(new Runnable() {
|
||||
public void run() {
|
||||
myTextArea.setForeground(XDebuggerUIConstants.ERROR_MESSAGE_ATTRIBUTES.getFgColor());
|
||||
myTextArea.setText(errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-11
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.xdebugger.frame.XCompositeNode;
|
||||
import com.intellij.xdebugger.frame.XFullValueEvaluator;
|
||||
import com.intellij.xdebugger.frame.XValue;
|
||||
import com.intellij.xdebugger.frame.XValueNode;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
@@ -39,10 +40,9 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
|
||||
private String myName;
|
||||
private String myType;
|
||||
private String myValue;
|
||||
private String myFullValue;
|
||||
private XFullValueEvaluator myFullValueEvaluator;
|
||||
private String mySeparator;
|
||||
private boolean myChanged;
|
||||
private String myLinkText;
|
||||
|
||||
public XValueNodeImpl(XDebuggerTree tree, final XDebuggerTreeNode parent, final XValue value) {
|
||||
super(tree, parent, value);
|
||||
@@ -74,11 +74,10 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
|
||||
});
|
||||
}
|
||||
|
||||
public void setFullValue(@NotNull final String fullValue, @NotNull final String linkText) {
|
||||
public void setFullValueEvaluator(@NotNull final XFullValueEvaluator fullValueEvaluator) {
|
||||
DebuggerUIUtil.invokeOnEventDispatch(new Runnable() {
|
||||
public void run() {
|
||||
myLinkText = linkText;
|
||||
myFullValue = fullValue;
|
||||
myFullValueEvaluator = fullValueEvaluator;
|
||||
fireNodeChanged();
|
||||
}
|
||||
});
|
||||
@@ -122,11 +121,11 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
|
||||
|
||||
@Override
|
||||
public XDebuggerNodeLink getLink() {
|
||||
if (myFullValue != null) {
|
||||
return new XDebuggerNodeLink(myLinkText) {
|
||||
if (myFullValueEvaluator != null) {
|
||||
return new XDebuggerNodeLink(myFullValueEvaluator.getLinkText()) {
|
||||
@Override
|
||||
public void onClick(MouseEvent event) {
|
||||
DebuggerUIUtil.showValuePopup(myFullValue, event, myTree.getProject());
|
||||
DebuggerUIUtil.showValuePopup(myFullValueEvaluator, event, myTree.getProject());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -135,9 +134,6 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
|
||||
|
||||
@Nullable
|
||||
public String getValue() {
|
||||
if (myFullValue != null) {
|
||||
return myFullValue;
|
||||
}
|
||||
return myValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ public class TestNGUtil implements TestFramework
|
||||
}
|
||||
|
||||
public static boolean isTestngXML(final VirtualFile virtualFile) {
|
||||
if (virtualFile.getName().endsWith("xml")) {
|
||||
if ("xml".equalsIgnoreCase(virtualFile.getExtension())) {
|
||||
final String result = NanoXmlUtil.parseHeader(virtualFile).getRootTagLocalName();
|
||||
if (result != null && result.equals(SUITE_TAG_NAME)) {
|
||||
return true;
|
||||
|
||||
@@ -1016,6 +1016,7 @@
|
||||
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticVariableRenamerFactory"/>
|
||||
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticParametersRenamerFactory"/>
|
||||
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticInheritorRenamerFactory"/>
|
||||
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.AutomaticTestRenamerFactory"/>
|
||||
<automaticRenamerFactory implementation="com.intellij.refactoring.rename.naming.ConstructorParameterOnFieldRenameRenamerFactory"/>
|
||||
|
||||
<nameSuggestionProvider implementation="com.intellij.refactoring.rename.JavaNameSuggestionProvider" id="java"/>
|
||||
|
||||
Reference in New Issue
Block a user