diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 45a529ff3d23..2a57fb8ff01b 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -145,6 +145,7 @@ binding.setVariable("loadProject", { def compilerOptions = JpsJavaExtensionService.instance.getOrCreateCompilerConfiguration(project).currentCompilerOptions compilerOptions.GENERATE_NO_WARNINGS = true compilerOptions.DEPRECATION = false + compilerOptions.ADDITIONAL_OPTIONS_STRING = compilerOptions.ADDITIONAL_OPTIONS_STRING.replace("-Xlint:unchecked", "") }) boolean hasSourceRoots(JpsModule module) { diff --git a/java/idea-ui/src/com/intellij/openapi/components/impl/stores/IdeaProjectStoreImpl.java b/java/idea-ui/src/com/intellij/openapi/components/impl/stores/IdeaProjectStoreImpl.java index 2c3165451113..95a44bcad324 100644 --- a/java/idea-ui/src/com/intellij/openapi/components/impl/stores/IdeaProjectStoreImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/components/impl/stores/IdeaProjectStoreImpl.java @@ -26,14 +26,14 @@ import org.jdom.Element; import org.jetbrains.annotations.NotNull; class IdeaProjectStoreImpl extends ProjectWithModulesStoreImpl { - public IdeaProjectStoreImpl(@NotNull ProjectImpl project) { - super(project); + public IdeaProjectStoreImpl(@NotNull ProjectImpl project, @NotNull PathMacroManager pathMacroManager) { + super(project, pathMacroManager); } @NotNull @Override protected StateStorageManager createStateStorageManager() { - return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject) { + return new ProjectStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myProject) { @Override public StorageData createIprStorageData(@NotNull String filePath) { return new IdeaIprStorageData(ROOT_TAG_NAME, myProject, filePath); diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_after.java new file mode 100644 index 000000000000..e33d32fd1c1b --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_after.java @@ -0,0 +1,10 @@ +public class Main { + + + public int a = 3; + protected Object obj = null; + private long e = 4; + + public static void main(String[] args) { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_before.java new file mode 100644 index 000000000000..c65c426808e3 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_before.java @@ -0,0 +1,17 @@ +import java.lang.Object; +import java.util.LinkedHashSet; +import java.util.Set; + +public class Main { + + + + public int a = 3; +private long e = 4; + + + protected Object obj = null; + + public static void main(String[] args) { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_revision.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_revision.java new file mode 100644 index 000000000000..c922c3a0fff4 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeVcsChanges_revision.java @@ -0,0 +1,10 @@ +import java.util.LinkedHashSet; +import java.util.Set; + +public class Main { + + + + public static void main(String[] args) { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_after.java new file mode 100644 index 000000000000..325157e34237 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_after.java @@ -0,0 +1,15 @@ +import java.util.List; + +public class Test { + + public long newRun; + public int ab; + public int awe; + private int c; + + public void run() { + List strings = null; + } + + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_before.java new file mode 100644 index 000000000000..40f2bdf8a1cd --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeRearrangeWholeFile_before.java @@ -0,0 +1,21 @@ +import java.util.HashMap; +import java.util.Set; +import java.util.List; + +public class Test { + + public long newRun; + + public void run() { + List strings = null; + } + + public int ab; + private int c; + + + public int awe; + + + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_after.java new file mode 100644 index 000000000000..d8b472a1ec80 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_after.java @@ -0,0 +1,23 @@ +import java.util.LinkedHashSet; +import java.util.Set; + +public class Main { + + + public static void main(String[] args) { + Runnable runnable = new Runnable() { + @Override + public void run() { + Set test = new LinkedHashSet(); + if (test.contains("AA")) { + if (test.contains("AS")) { + System.out.println("AAAA!"); + } + } + } + }; + + runnable.run(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_before.java new file mode 100644 index 000000000000..8d972e12b704 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_before.java @@ -0,0 +1,27 @@ +import java.lang.Override; +import java.lang.Runnable; +import java.lang.String; +import java.util.Set; +import java.util.HashSet; +import java.util.LinkedHashSet; + +public class Main { + + + public static void main(String[] args) { + Runnable runnable = new Runnable() { + @Override + public void run() { + Set test = new LinkedHashSet(); + if (test.contains("AA")) { + if (test.contains("AS")) { + System.out.println("AAAA!"); + } + } + } + }; + + runnable.run(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_revision.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_revision.java new file mode 100644 index 000000000000..0818983f8e7d --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeVcsChanges_revision.java @@ -0,0 +1,23 @@ +import com.intellij.util.containers.HashSet; + +import java.util.Set; +import java.util.HashSet; + +public class Main { + + + public static void main(String[] args) { + Runnable runnable = new Runnable() { + @Override + public void run() { + Set test = new HashSet(); + if (test.contains("AA")) { + System.out.println("AAAA!"); + } + } + }; + + runnable.run(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_after.java new file mode 100644 index 000000000000..1a0c071acd66 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_after.java @@ -0,0 +1,10 @@ +import java.util.List; + +public class Test { + + + public void run() { + List strings = null; + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_before.java new file mode 100644 index 000000000000..26f115f2588b --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatOptimizeWholeFile_before.java @@ -0,0 +1,12 @@ +import java.util.HashMap; +import java.util.Set; +import java.util.List; + +public class Test { + + + public void run() { + List strings = null; + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_after.java new file mode 100644 index 000000000000..fb22c27cefc8 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_after.java @@ -0,0 +1,9 @@ +class Test { + + public int a = 3; + private int b = 3; + + +public void run () {} +int aero = 12; +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_before.java new file mode 100644 index 000000000000..0f1201c936ea --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatRearrangeSelection_before.java @@ -0,0 +1,9 @@ +class Test { + + private int b = 3; +public int a = 3; + + +public void run () {} +int aero = 12; +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_after.java new file mode 100644 index 000000000000..357b4779dc09 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_after.java @@ -0,0 +1,15 @@ +public class Test { + + int a = 3; + + int c = 12; + + public void run() { + + int arr = 12; + long test = 1; + + } + + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_before.java new file mode 100644 index 000000000000..c28ea3ea10db --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatSelection_before.java @@ -0,0 +1,15 @@ +public class Test { + + int a = 3; + + int c = 12; + + public void run() { + + int arr = 12; +long test =1; + + } + + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_after.java new file mode 100644 index 000000000000..17cc8ec1273f --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_after.java @@ -0,0 +1,13 @@ +public class Test { + +public void run() { + + int a = 3; + int b = 12; + +} + + public void test() { + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_before.java new file mode 100644 index 000000000000..5a92198fefee --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_before.java @@ -0,0 +1,13 @@ +public class Test { + +public void run() { + +int a = 3; +int b = 12; + +} + +public void test() { +} + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_revision.java b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_revision.java new file mode 100644 index 000000000000..c7c76f24f5a0 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatVcsChanges_revision.java @@ -0,0 +1,10 @@ +public class Test { + +public void run() { + + int a = 3; + +} + + +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_after.java b/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_after.java new file mode 100644 index 000000000000..837621dd5421 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_after.java @@ -0,0 +1,8 @@ +public class Test { + + int a = 3; + + + void run() { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_before.java b/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_before.java new file mode 100644 index 000000000000..d20b5115dd61 --- /dev/null +++ b/java/java-tests/testData/actions/reformatFileInEditor/formatWholeFile_before.java @@ -0,0 +1,9 @@ +public class Test { + + int a = 3; + + +void run() +{ +} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/actions/ReformatCodeActionInEditorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/actions/ReformatCodeActionInEditorTest.java new file mode 100644 index 000000000000..286de18ffd6d --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/actions/ReformatCodeActionInEditorTest.java @@ -0,0 +1,121 @@ +/* + * Copyright 2000-2014 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.codeInsight.actions; + +import com.intellij.JavaTestUtil; +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.changes.Change; +import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.psi.PsiFile; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ReformatCodeActionInEditorTest extends LightCodeInsightFixtureTestCase { + + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/actions/reformatFileInEditor/"; + } + + public void doTest(@NotNull ReformatFilesOptions options) { + setOptions(options); + + String before = null; + if (options.isProcessOnlyChangedText()) { + myFixture.configureByFile(getTestDataPath() + getTestName(true) + "_revision.java"); + PsiFile file = myFixture.getFile(); + Document document = myFixture.getDocument(file); + before = document.getText(); + } + + myFixture.configureByFile(getTestDataPath() + getTestName(true) + "_before.java"); + + if (before != null) { + myFixture.getFile().putUserData(FormatChangedTextUtil.TEST_REVISION_CONTENT, before); + } + + final String actionId = IdeActions.ACTION_EDITOR_REFORMAT; + AnAction action = ActionManager.getInstance().getAction(actionId); + + AnActionEvent event = createEventFor(action, getProject(), myFixture.getEditor()); + + action.actionPerformed(event); + myFixture.checkResultByFile(getTestName(true) + "_after.java"); + } + + @Override + public void tearDown() throws Exception { + myFixture.getFile().putUserData(FormatChangedTextUtil.TEST_REVISION_CONTENT, null); + super.tearDown(); + } + + protected AnActionEvent createEventFor(@NotNull AnAction action, @NotNull final Project project, @NotNull final Editor editor) { + return new AnActionEvent(null, new DataContext() { + @Nullable + @Override + public Object getData(@NonNls String dataId) { + if (CommonDataKeys.PROJECT.is(dataId)) return project; + if (CommonDataKeys.EDITOR.is(dataId)) return editor; + return null; + } + }, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0); + } + + protected void setOptions(ReformatFilesOptions options) { + ReformatCodeAction.setTestOptions(options); + } + + public void testFormatWholeFile() { + doTest(new MockReformatFileSettings().setProcessWholeFile(true)); + } + + public void testFormatOptimizeWholeFile() { + doTest(new MockReformatFileSettings().setProcessWholeFile(true).setOptimizeImports(true)); + } + + public void testFormatOptimizeRearrangeWholeFile() { + doTest(new MockReformatFileSettings().setProcessWholeFile(true).setOptimizeImports(true).setRearrange(true)); + } + + public void testFormatSelection() { + doTest(new MockReformatFileSettings().setProcessWholeFile(false)); + } + + public void testFormatRearrangeSelection() { + doTest(new MockReformatFileSettings().setProcessWholeFile(false).setRearrange(true)); + } + + public void testFormatVcsChanges() { + doTest(new MockReformatFileSettings().setProcessOnlyChangedText(true)); + } + + public void testFormatOptimizeVcsChanges() { + doTest(new MockReformatFileSettings().setProcessOnlyChangedText(true).setOptimizeImports(true)); + } + + public void testFormatOptimizeRearrangeVcsChanges() { + doTest(new MockReformatFileSettings().setProcessOnlyChangedText(true).setOptimizeImports(true).setRearrange(true)); + } + +} diff --git a/java/java-tests/testSrc/com/intellij/projectView/NavigateFromSourceTest.java b/java/java-tests/testSrc/com/intellij/projectView/NavigateFromSourceTest.java index b26afb406d5b..c27aa2c38052 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/NavigateFromSourceTest.java +++ b/java/java-tests/testSrc/com/intellij/projectView/NavigateFromSourceTest.java @@ -115,7 +115,7 @@ public class NavigateFromSourceTest extends BaseProjectViewTestCase { pane.select(psiClass, psiClass.getContainingFile().getVirtualFile(), true); - assertEquals(9, tree.getSelectionCount()); + assertEquals(8, tree.getSelectionCount()); } private static void changeClassTextAndTryToNavigate(final String newClassString, diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java index a82c941c0fa2..a1d505a40259 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java @@ -33,6 +33,7 @@ class JavaPredefinedConfigurations { createSearchTemplateInfo(SSRBundle.message("predefined.configuration.string.literals"),"\"'_String\"",EXPRESSION_TYPE), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.all.expressions.of.some.type"),"'_Expression:[exprtype( SomeType )]",EXPRESSION_TYPE), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.sample.method.invokation.with.constant.argument"),"Integer.parseInt('_a:[script( \"com.intellij.psi.util.PsiUtil.isConstantExpression(__context__)\" )])",EXPRESSION_TYPE), + createSearchTemplateInfo(SSRBundle.message("predefined.configuration.method.references"), "'_Qualifier::'methodName", EXPRESSION_TYPE), // Operators createSearchTemplateInfo(SSRBundle.message("predefined.configuration.block.dcls"),"{\n '_Type+ 'Var+ = '_Init*;\n '_BlockStatements*;\n}",OPERATOR_TYPE), @@ -90,7 +91,7 @@ class JavaPredefinedConfigurations { ), createSearchTemplateInfo( SSRBundle.message("predefined.configuration.implementors.of.interface.within.hierarchy"), - "class 'Class implements 'Interface:* {}", + "class 'Class implements '_Interface:* {}", CLASS_TYPE ), createSearchTemplateInfo( @@ -165,6 +166,7 @@ class JavaPredefinedConfigurations { createSearchTemplateInfo(SSRBundle.message("predefined.configuration.generic.casts"),"( '_Type <'_GenericArgument+> ) '_Expr", GENERICS_TYPE), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.type.var.substitutions.in.intanceof.with.generic.types"),"'_Expr instanceof '_Type <'Substitutions+> ", GENERICS_TYPE), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.variables.of.generic.types"),"'_Type <'_GenericArgument+> 'Var = 'Init?;", GENERICS_TYPE), + createSearchTemplateInfo(SSRBundle.message("predefined.configuration.diamond.operators"), "new 'ClassName<>('_Argument*)", GENERICS_TYPE), // Add comments and metadata createSearchTemplateInfo(SSRBundle.message("predefined.configuration.comments"),"/* 'CommentContent */", METADATA_TYPE), diff --git a/java/testFramework/src/com/intellij/testFramework/TestSourceBasedTestCase.java b/java/testFramework/src/com/intellij/testFramework/TestSourceBasedTestCase.java index 55b55c55dfb7..0f4c5a1f53ef 100644 --- a/java/testFramework/src/com/intellij/testFramework/TestSourceBasedTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/TestSourceBasedTestCase.java @@ -15,7 +15,6 @@ */ package com.intellij.testFramework; -import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; @@ -101,7 +100,6 @@ import java.io.File; } protected String getRootFiles() { - return " " + myModule.getModuleFile().getName() + "\n" + - " " + myProject.getName() + ProjectFileType.DOT_DEFAULT_EXTENSION + "\n"; + return " " + myModule.getModuleFile().getName() + "\n"; } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 4ce05d3d09bf..f55d73b8d6da 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -602,8 +602,10 @@ public class JavaBuilder extends ModuleLevelBuilder { if (baseDirectory != null) { //this is a temporary workaround to allow passing per-module compiler options for Eclipse compiler in form // -properties $MODULE_DIR$/.settings/org.eclipse.jdt.core.prefs + String stringToReplace = "$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$"; + String moduleDirPath = FileUtil.toCanonicalPath(baseDirectory.getAbsolutePath()); for (String s : cached) { - options.add(StringUtil.replace(s, "$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$", baseDirectory.getAbsolutePath())); + options.add(StringUtil.replace(s, stringToReplace, moduleDirPath)); } } else { diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java index e7198b5ac44b..bb197ca6b683 100644 --- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java +++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java @@ -120,11 +120,11 @@ public class HighlightDisplayLevel { @NotNull public static Icon createIconByMask(final Color renderColor) { - return new TheColorIcon(getEmptyIconDim(), renderColor); + return new MyColorIcon(getEmptyIconDim(), renderColor); } - public static class TheColorIcon extends ColorIcon implements ColoredIcon { - public TheColorIcon(int size, @NotNull Color color) { + private static class MyColorIcon extends ColorIcon implements ColoredIcon { + public MyColorIcon(int size, @NotNull Color color) { super(size, color); } @@ -132,12 +132,12 @@ public class HighlightDisplayLevel { public Color getColor() { return getIconColor(); } - } - + } + public interface ColoredIcon { Color getColor(); } - + public static class SingleColorIcon implements Icon, ColoredIcon { private final TextAttributesKey myKey; diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java index de4c9612f46e..a6a9770223a6 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java @@ -94,16 +94,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator fileToPsiFileMap = new THashMap(myVFileToViewProviderMap); + myVFileToViewProviderMap.clear(); + for (Iterator iterator = fileToPsiFileMap.keySet().iterator(); iterator.hasNext();) { + VirtualFile vFile = iterator.next(); + Language language = getLanguage(vFile); + if (language != null && language != fileToPsiFileMap.get(vFile).getBaseLanguage()) { + iterator.remove(); + } + } + myVFileToViewProviderMap.putAll(fileToPsiFileMap); + } + public void forceReload(@NotNull VirtualFile vFile) { if (findCachedViewProvider(vFile) == null) { return; @@ -231,6 +245,11 @@ public class FileManagerImpl implements FileManager { @NotNull public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, boolean eventSystemEnabled) { Language language = getLanguage(file); + return createFileViewProvider(file, eventSystemEnabled, language); + } + + @NotNull + private FileViewProvider createFileViewProvider(@NotNull VirtualFile file, boolean eventSystemEnabled, Language language) { final FileViewProviderFactory factory = language == null ? FileTypeFileViewProviders.INSTANCE.forFileType(file.getFileType()) : LanguageFileViewProviders.INSTANCE.forLanguage(language); diff --git a/platform/icons/src/welcome/project/remove-hover.png b/platform/icons/src/welcome/project/remove-hover.png new file mode 100755 index 000000000000..5ad066031a0b Binary files /dev/null and b/platform/icons/src/welcome/project/remove-hover.png differ diff --git a/platform/icons/src/welcome/project/remove-hover@2x.png b/platform/icons/src/welcome/project/remove-hover@2x.png new file mode 100755 index 000000000000..92e81d2c62c2 Binary files /dev/null and b/platform/icons/src/welcome/project/remove-hover@2x.png differ diff --git a/platform/icons/src/welcome/project/remove-hover@2x_dark.png b/platform/icons/src/welcome/project/remove-hover@2x_dark.png new file mode 100755 index 000000000000..45670e6f8640 Binary files /dev/null and b/platform/icons/src/welcome/project/remove-hover@2x_dark.png differ diff --git a/platform/icons/src/welcome/project/remove-hover_dark.png b/platform/icons/src/welcome/project/remove-hover_dark.png new file mode 100755 index 000000000000..5db2a4a66d93 Binary files /dev/null and b/platform/icons/src/welcome/project/remove-hover_dark.png differ diff --git a/platform/icons/src/welcome/project/remove.png b/platform/icons/src/welcome/project/remove.png new file mode 100755 index 000000000000..1e33bb2efd8c Binary files /dev/null and b/platform/icons/src/welcome/project/remove.png differ diff --git a/platform/icons/src/welcome/project/remove@2x.png b/platform/icons/src/welcome/project/remove@2x.png new file mode 100755 index 000000000000..95684493f363 Binary files /dev/null and b/platform/icons/src/welcome/project/remove@2x.png differ diff --git a/platform/icons/src/welcome/project/remove@2x_dark.png b/platform/icons/src/welcome/project/remove@2x_dark.png new file mode 100755 index 000000000000..3f9d3eba22e7 Binary files /dev/null and b/platform/icons/src/welcome/project/remove@2x_dark.png differ diff --git a/platform/icons/src/welcome/project/remove_dark.png b/platform/icons/src/welcome/project/remove_dark.png new file mode 100755 index 000000000000..4238c74433de Binary files /dev/null and b/platform/icons/src/welcome/project/remove_dark.png differ diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java index 72e30785d0c2..2585d91728c3 100644 --- a/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java +++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java @@ -114,26 +114,8 @@ class PrintManager { painter = new MultiFilePainter(filesList); } - Pageable document = new Pageable() { - @Override - public int getNumberOfPages() { - return Pageable.UNKNOWN_NUMBER_OF_PAGES; - } - - @Override - public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException { - return pageFormat; - } - - @Override - public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException { - return painter; - } - }; - final PrinterJob printerJob = PrinterJob.getPrinterJob(); try { - printerJob.setPageable(document); printerJob.setPrintable(painter, pageFormat); if (!printerJob.printDialog()) { return; @@ -230,7 +212,8 @@ class PrintManager { if (doc == null) return null; EditorHighlighter highlighter = HighlighterFactory.createHighlighter(psiFile.getProject(), virtualFile); highlighter.setText(doc.getCharsSequence()); - return new TextPainter(doc, highlighter, virtualFile.getPresentableUrl(), psiFile, psiFile.getFileType(), editor); + return new TextPainter(doc, highlighter, virtualFile.getPresentableUrl(), virtualFile.getPresentableName(), + psiFile, psiFile.getFileType(), editor); } private static TextPainter initTextPainter(@NotNull final DocumentEx doc, final Project project) { @@ -249,6 +232,6 @@ class PrintManager { private static TextPainter doInitTextPainter(@NotNull final DocumentEx doc, Project project) { EditorHighlighter highlighter = HighlighterFactory.createHighlighter(project, "unknown"); highlighter.setText(doc.getCharsSequence()); - return new TextPainter(doc, highlighter, "unknown", project, FileTypes.PLAIN_TEXT, null); + return new TextPainter(doc, highlighter, "unknown", "unknown", project, FileTypes.PLAIN_TEXT, null); } } diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java index 22a420b725a8..7c84f5e637aa 100644 --- a/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java +++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java @@ -28,6 +28,7 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; @@ -45,6 +46,8 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.PrinterException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; class TextPainter extends BasePainter { @@ -62,32 +65,48 @@ class TextPainter extends BasePainter { private final Font myHeaderFont; private final EditorHighlighter myHighlighter; private final PrintSettings myPrintSettings; - private final String myFileName; + private final String myFullFileName; + private final String myShortFileName; private int myPageIndex; + private int myNumberOfPages = -1; private int mySegmentEnd; private final LineMarkerInfo[] myMethodSeparators; private int myCurrentMethodSeparator; private final CodeStyleSettings myCodeStyleSettings; private final FileType myFileType; + private boolean myPerformActualDrawing; + + private final String myPrintDate; + private final String myPrintTime; @NonNls private static final String DEFAULT_MEASURE_HEIGHT_TEXT = "A"; @NonNls private static final String DEFAULT_MEASURE_WIDTH_TEXT = "w"; + @NonNls private static final String HEADER_TOKEN_PAGE = "PAGE"; + @NonNls private static final String HEADER_TOKEN_TOTALPAGES = "TOTALPAGES"; @NonNls private static final String HEADER_TOKEN_FILE = "FILE"; + @NonNls private static final String HEADER_TOKEN_FILENAME = "FILENAME"; + @NonNls private static final String HEADER_TOKEN_DATE = "DATE"; + @NonNls private static final String HEADER_TOKEN_TIME = "TIME"; + + @NonNls private static final String DATE_FORMAT = "yyyy-MM-dd"; + @NonNls private static final String TIME_FORMAT = "HH:mm:ss"; public TextPainter(@NotNull DocumentEx editorDocument, EditorHighlighter highlighter, - String fileName, + String fullFileName, + String shortFileName, @NotNull PsiFile psiFile, FileType fileType, Editor editor) { - this(editorDocument, highlighter, fileName, psiFile.getProject(), fileType, + this(editorDocument, highlighter, fullFileName, shortFileName, psiFile.getProject(), fileType, FileSeparatorProvider.getInstance().getFileSeparators(psiFile, editorDocument, editor)); } public TextPainter(@NotNull DocumentEx editorDocument, EditorHighlighter highlighter, - String fileName, + String fullFileName, + String shortFileName, Project project, FileType fileType, List separators) { @@ -102,18 +121,26 @@ class TextPainter extends BasePainter { myBoldItalicFont = new Font(fontName, Font.BOLD | Font.ITALIC, fontSize); myHighlighter = highlighter; myHeaderFont = new Font(myPrintSettings.FOOTER_HEADER_FONT_NAME, Font.PLAIN, myPrintSettings.FOOTER_HEADER_FONT_SIZE); - myFileName = fileName; + myFullFileName = fullFileName; + myShortFileName = shortFileName; myRangeToPrint = editorDocument.createRangeMarker(0, myDocument.getTextLength()); myFileType = fileType; myMethodSeparators = separators != null ? separators.toArray(new LineMarkerInfo[separators.size()]) : new LineMarkerInfo[0]; myCurrentMethodSeparator = 0; + Date date = new Date(); + myPrintDate = new SimpleDateFormat(DATE_FORMAT).format(date); + myPrintTime = new SimpleDateFormat(TIME_FORMAT).format(date); } public void setSegment(int segmentStart, int segmentEnd) { + setSegment(myDocument.createRangeMarker(segmentStart, segmentEnd)); + } + + private void setSegment(RangeMarker marker) { if (myRangeToPrint != null) { myRangeToPrint.dispose(); } - myRangeToPrint = myDocument.createRangeMarker(segmentStart, segmentEnd); + myRangeToPrint = marker; } private float getLineHeight(Graphics g) { @@ -151,42 +178,104 @@ class TextPainter extends BasePainter { @Override public int print(final Graphics g, final PageFormat pageFormat, final int pageIndex) throws PrinterException { + if (myProgress.isCanceled()) { + return NO_SUCH_PAGE; + } + + final Graphics2D g2d = (Graphics2D)g; + + if (myNumberOfPages < 0) { + myProgress.setText(CodeEditorBundle.message("print.file.calculating.number.of.pages.progress")); + + myPerformActualDrawing = false; + + if (!calculateNumberOfPages(g2d, pageFormat)) { + return NO_SUCH_PAGE; + } + } + + myPerformActualDrawing = true; + return ApplicationManager.getApplication().runReadAction(new Computable() { @Override public Integer compute() { - if (myProgress.isCanceled() || myRangeToPrint == null || !myRangeToPrint.isValid()) { + if (!isValidRange(myRangeToPrint)) { return NO_SUCH_PAGE; } - int startOffset = myRangeToPrint.getStartOffset(); - myOffset = startOffset; - mySegmentEnd = myRangeToPrint.getEndOffset(); - myLineNumber = myDocument.getLineNumber(myOffset) + 1; - if (myOffset >= mySegmentEnd) { - return NO_SUCH_PAGE; - } isPrintingPass = !isPrintingPass; if (!isPrintingPass) { return PAGE_EXISTS; } - myProgress.setText(CodeEditorBundle.message("print.file.page.progress", myFileName, (pageIndex + 1))); + myProgress.setText(CodeEditorBundle.message("print.file.page.progress", myShortFileName, (pageIndex + 1), myNumberOfPages)); myPageIndex = pageIndex; - Graphics2D g2D = (Graphics2D) g; - Rectangle2D.Double clip = new Rectangle2D.Double(pageFormat.getImageableX(), pageFormat.getImageableY(), - pageFormat.getImageableWidth(), - pageFormat.getImageableHeight()); - draw(g2D, clip); + RangeMarker newRange = printPage(g2d, pageFormat, myRangeToPrint); + setSegment(newRange); - myRangeToPrint.dispose(); - // stop printing if there was no progress (to avoid an infinite loop) or if the whole range was processed - myRangeToPrint = myOffset > startOffset && myOffset < mySegmentEnd ? myDocument.createRangeMarker(myOffset, mySegmentEnd) : null; return PAGE_EXISTS; } }); } + private boolean calculateNumberOfPages(final Graphics2D g2d, final PageFormat pageFormat) { + myNumberOfPages = 0; + final Ref firstPage = new Ref(Boolean.TRUE); + final Ref tmpMarker = new Ref(); + while (ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + if (firstPage.get()) { + if (!isValidRange(myRangeToPrint)) { + return false; + } + tmpMarker.set(myDocument.createRangeMarker(myRangeToPrint.getStartOffset(), myRangeToPrint.getEndOffset())); + firstPage.set(Boolean.FALSE); + } + RangeMarker range = tmpMarker.get(); + if (!isValidRange(range)) { + return false; + } + tmpMarker.set(printPage(g2d, pageFormat, range)); + range.dispose(); + return true; + } + })) { + if (myProgress.isCanceled()) { + return false; + } + myNumberOfPages++; + } + if (!tmpMarker.isNull()) { + tmpMarker.get().dispose(); + } + return true; + } + + private static boolean isValidRange(RangeMarker range) { + return range != null && range.isValid() && range.getStartOffset() < range.getEndOffset(); + } + + /** + * Prints a pageful of text from a given range. Return a remaining range to print, or null if there's nothing left. + */ + private RangeMarker printPage(Graphics2D g2d, PageFormat pageFormat, RangeMarker range) { + assert isValidRange(range); + int startOffset = range.getStartOffset(); + int endOffset = range.getEndOffset(); + + myOffset = startOffset; + mySegmentEnd = endOffset; + myLineNumber = myDocument.getLineNumber(myOffset) + 1; + Rectangle2D.Double clip = new Rectangle2D.Double(pageFormat.getImageableX(), pageFormat.getImageableY(), + pageFormat.getImageableWidth(), pageFormat.getImageableHeight()); + + draw(g2d, clip); + + return myOffset > startOffset && myOffset < endOffset ? myDocument.createRangeMarker(myOffset, endOffset) : null; + } + private void draw(Graphics2D g2D, Rectangle2D.Double clip) { double headerHeight = drawHeader(g2D, clip); clip.y += headerHeight; @@ -209,7 +298,7 @@ class TextPainter extends BasePainter { } private void drawBorder(Graphics2D g, Rectangle2D clip) { - if (myPrintSettings.DRAW_BORDER) { + if (myPrintSettings.DRAW_BORDER && myPerformActualDrawing) { Color save = g.getColor(); g.setColor(Color.black); g.draw(clip); @@ -270,10 +359,8 @@ class TextPainter extends BasePainter { Point2D position = new Point2D.Double(0, clip.getY()); double lineY = position.getY(); - while (myCurrentMethodSeparator < myMethodSeparators.length) { - LineMarkerInfo marker = myMethodSeparators[myCurrentMethodSeparator]; - if (marker != null && marker.startOffset >= lIterator.getEnd()) break; - myCurrentMethodSeparator++; + if (myPerformActualDrawing) { + setInitialMethodSeparatorIndex(lIterator.getEnd()); } while (!hIterator.atEnd() && !lIterator.atEnd()) { @@ -290,14 +377,13 @@ class TextPainter extends BasePainter { lIterator.advance(); myLineNumber++; - if (myCurrentMethodSeparator < myMethodSeparators.length) { - LineMarkerInfo marker = myMethodSeparators[myCurrentMethodSeparator]; - if (marker != null && marker.startOffset < lEnd) { + if (myPerformActualDrawing) { + LineMarkerInfo marker = getMethodSeparator(lEnd); + if (marker != null) { Color save = g.getColor(); setForegroundColor(g, marker.separatorColor); UIUtil.drawLine(g, 0, (int)lineY, (int)clip.getWidth(), (int)lineY); setForegroundColor(g, save); - myCurrentMethodSeparator++; } } @@ -343,6 +429,25 @@ class TextPainter extends BasePainter { g.translate(-clip.getX(), 0); } + + private void setInitialMethodSeparatorIndex(int initialOffset) { + while (myCurrentMethodSeparator < myMethodSeparators.length) { + LineMarkerInfo marker = myMethodSeparators[myCurrentMethodSeparator]; + if (marker != null && marker.startOffset >= initialOffset) break; + myCurrentMethodSeparator++; + } + } + + private LineMarkerInfo getMethodSeparator(int currentOffset) { + if (myCurrentMethodSeparator < myMethodSeparators.length) { + LineMarkerInfo marker = myMethodSeparators[myCurrentMethodSeparator]; + if (marker != null && marker.startOffset < currentOffset) { + myCurrentMethodSeparator++; + return marker; + } + } + return null; + } private double drawHeader(Graphics2D g, Rectangle2D clip) { LineMetrics lineMetrics = getHeaderFooterLineMetrics(g); @@ -407,21 +512,23 @@ class TextPainter extends BasePainter { private double drawHeaderOrFooterLine(Graphics2D g, double x, double y, double w, String headerText, String alignment) { - headerText = convertHeaderText(headerText); - g.setFont(myHeaderFont); - g.setColor(Color.black); FontRenderContext fontRenderContext = g.getFontRenderContext(); LineMetrics lineMetrics = getHeaderFooterLineMetrics(g); float lineHeight = lineMetrics.getHeight(); - float descent = lineMetrics.getDescent(); - double width = myHeaderFont.getStringBounds(headerText, fontRenderContext).getWidth() + getCharWidth(g); - float yPos = (float) (lineHeight - descent + y); - if (PrintSettings.LEFT.equals(alignment)) { - drawStringToGraphics(g, headerText, x, yPos); - } else if (PrintSettings.CENTER.equals(alignment)) { - drawStringToGraphics(g, headerText, (float) (x + (w - width) / 2), yPos); - } else if (PrintSettings.RIGHT.equals(alignment)) { - drawStringToGraphics(g, headerText, (float) (x + w - width), yPos); + if (myPerformActualDrawing) { + headerText = convertHeaderText(headerText); + g.setFont(myHeaderFont); + g.setColor(Color.black); + float descent = lineMetrics.getDescent(); + double width = myHeaderFont.getStringBounds(headerText, fontRenderContext).getWidth() + getCharWidth(g); + float yPos = (float) (lineHeight - descent + y); + if (PrintSettings.LEFT.equals(alignment)) { + drawStringToGraphics(g, headerText, x, yPos); + } else if (PrintSettings.CENTER.equals(alignment)) { + drawStringToGraphics(g, headerText, (float) (x + (w - width) / 2), yPos); + } else if (PrintSettings.RIGHT.equals(alignment)) { + drawStringToGraphics(g, headerText, (float) (x + w - width), yPos); + } } return lineHeight; } @@ -437,8 +544,16 @@ class TextPainter extends BasePainter { if (isExpression) { if (HEADER_TOKEN_PAGE.equals(token)) { result.append(myPageIndex + 1); + } else if (HEADER_TOKEN_TOTALPAGES.equals(token)) { + result.append(myNumberOfPages); } else if (HEADER_TOKEN_FILE.equals(token)) { - result.append(myFileName); + result.append(myFullFileName); + } else if (HEADER_TOKEN_FILENAME.equals(token)) { + result.append(myShortFileName); + } else if (HEADER_TOKEN_DATE.equals(token)) { + result.append(myPrintDate); + } else if (HEADER_TOKEN_TIME.equals(token)) { + result.append(myPrintTime); } } else { result.append(token); @@ -475,7 +590,7 @@ class TextPainter extends BasePainter { } private void drawLineNumber(Graphics2D g, double x, double y) { - if (!myPrintSettings.PRINT_LINE_NUMBERS) { + if (!myPrintSettings.PRINT_LINE_NUMBERS || !myPerformActualDrawing) { return; } FontRenderContext fontRenderContext = (g).getFontRenderContext(); @@ -538,7 +653,7 @@ class TextPainter extends BasePainter { double xStart = position.getX(); double x = position.getX(); double y = getLineHeight(g) - getDescent(g) + position.getY(); - if (backColor != null) { + if (backColor != null && myPerformActualDrawing) { Color savedColor = g.getColor(); setBackgroundColor(g, backColor); double w = getTextSegmentWidth(text, myOffset, length, position.getX(), g); @@ -567,7 +682,7 @@ class TextPainter extends BasePainter { x += drawStringToGraphics(g, s, x, y); } - if (underscoredColor != null) { + if (underscoredColor != null && myPerformActualDrawing) { Color savedColor = g.getColor(); setForegroundColor(g, underscoredColor); double w = getTextSegmentWidth(text, myOffset, length, position.getX(), g); @@ -581,13 +696,17 @@ class TextPainter extends BasePainter { private double drawStringToGraphics(Graphics2D g, String s, double x, double y) { if (!myPrintSettings.PRINT_AS_GRAPHICS) { - g.drawString(s, (float) x, (float) y); + if (myPerformActualDrawing) { + g.drawString(s, (float)x, (float)y); + } return g.getFontMetrics().stringWidth(s); } else { GlyphVector v = g.getFont().createGlyphVector(g.getFontRenderContext(), s); - g.translate(x, y); - g.fill(v.getOutline()); - g.translate(-x, -y); + if (myPerformActualDrawing) { + g.translate(x, y); + g.fill(v.getOutline()); + g.translate(-x, -y); + } return v.getLogicalBounds().getWidth(); } @@ -635,9 +754,6 @@ class TextPainter extends BasePainter { @Override void dispose() { - if (myRangeToPrint != null) { - myRangeToPrint.dispose(); - myRangeToPrint = null; - } + setSegment(null); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java index 45effe8e781e..03691d0749e0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInsight.actions; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.application.Result; import com.intellij.openapi.diagnostic.Logger; @@ -27,6 +28,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; @@ -52,8 +54,9 @@ import org.jetbrains.annotations.Nullable; import java.util.*; public class FormatChangedTextUtil { + public static final Key TEST_REVISION_CONTENT = Key.create("test.revision.content"); private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.actions.FormatChangedTextUtil"); - + private FormatChangedTextUtil() { } @@ -251,6 +254,13 @@ public class FormatChangedTextUtil { return cachedChangedLines; } + if (ApplicationManager.getApplication().isUnitTestMode()) { + String testContent = file.getUserData(TEST_REVISION_CONTENT); + if (testContent != null) { + return calculateChangedTextRanges(file.getProject(), file, testContent); + } + } + Change change = ChangeListManager.getInstance(project).getChange(file.getVirtualFile()); if (change == null) { return ContainerUtilRt.emptyList(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java index b34fcb858108..4dbdefc6c8ec 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java @@ -45,6 +45,11 @@ public class RearrangeCodeProcessor extends AbstractLayoutCodeProcessor { public RearrangeCodeProcessor(@NotNull AbstractLayoutCodeProcessor previousProcessor) { super(previousProcessor, COMMAND_NAME, PROGRESS_TEXT); } + + public RearrangeCodeProcessor(@NotNull AbstractLayoutCodeProcessor previousProcessor, @NotNull SelectionModel selectionModel) { + super(previousProcessor, COMMAND_NAME, PROGRESS_TEXT); + mySelectionModel = selectionModel; + } public RearrangeCodeProcessor(@NotNull Project project, @NotNull PsiFile file, diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index bcbd0fd6738d..d21ec363fd55 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -192,8 +192,13 @@ public class ReformatCodeAction extends AnAction implements DumbAware { processor = new ReformatCodeProcessor(project, file, range, !processSelectedText && processChangedTextOnly); } - if (rearrangeEntries && editor != null) { - processor = new RearrangeCodeProcessor(processor); + if (rearrangeEntries) { + if (processSelectedText && editor != null) { + processor = new RearrangeCodeProcessor(processor, editor.getSelectionModel()); + } + else { + processor = new RearrangeCodeProcessor(processor); + } } processor.run(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java index f5c48dc42ae6..e72ee5399f47 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java @@ -325,12 +325,24 @@ public class SeverityEditorDialog extends DialogWrapper { final ListModel listModel = myOptionsList.getModel(); final List order = new ArrayList(); for (int i = listModel.getSize() - 1; i >= 0; i--) { - final SeverityBasedTextAttributes info = - (SeverityBasedTextAttributes)listModel.getElementAt(i); + SeverityBasedTextAttributes info = (SeverityBasedTextAttributes)listModel.getElementAt(i); order.add(info.getSeverity()); if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) { infoTypes.remove(info); final Color stripeColor = info.getAttributes().getErrorStripeColor(); + final boolean exists = mySeverityRegistrar.getSeverity(info.getSeverity().getName()) != null; + if (exists) { + info.getType().getAttributesKey().getDefaultAttributes().setErrorStripeColor(stripeColor); + } else { + HighlightInfoType.HighlightInfoTypeImpl type = info.getType(); + TextAttributesKey key = type.getAttributesKey(); + final TextAttributes defaultAttributes = key.getDefaultAttributes().clone(); + defaultAttributes.setErrorStripeColor(stripeColor); + key = TextAttributesKey.createTextAttributesKey(key.getExternalName(), defaultAttributes); + type = new HighlightInfoType.HighlightInfoTypeImpl(type.getSeverity(null), key); + info = new SeverityBasedTextAttributes(info.getAttributes(), type); + } + mySeverityRegistrar.registerSeverity(info, stripeColor != null ? stripeColor : LightColors.YELLOW); } } diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java index e4362587abbb..22699f8ebae2 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java @@ -149,7 +149,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc @Override public String getDisplayName() { - return IdeBundle.message("title.file.templates"); + return IdeBundle.message("title.edit.file.template"); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java index aedc584d1a36..fe126a1eb7a6 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java @@ -33,7 +33,6 @@ import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.SystemProperties; import com.intellij.util.text.DateFormatUtil; @@ -118,9 +117,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers @NotNull @Override public String getTemplatesDir() { - VirtualFile file = project.getProjectFile(); - assert file != null; - return new File(file.getParent().getCanonicalPath(), TEMPLATES_DIR).getPath(); + return new File(project.getBasePath(), Project.DIRECTORY_STORE_FOLDER + "/" + TEMPLATES_DIR).getPath(); } }; } diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java index 26da55cbc21a..33e9be8eeadb 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java @@ -17,7 +17,6 @@ package com.intellij.openapi.components.impl.stores; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; -import com.intellij.openapi.components.impl.ComponentManagerImpl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleTypeManager; @@ -47,8 +46,9 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM private final ModuleImpl myModule; @SuppressWarnings({"UnusedDeclaration"}) - public ModuleStoreImpl(@NotNull ComponentManagerImpl componentManager, @NotNull ModuleImpl module) { - super(componentManager); + public ModuleStoreImpl(@NotNull ModuleImpl module, @NotNull PathMacroManager pathMacroManager) { + super(pathMacroManager); + myModule = module; } @@ -252,6 +252,6 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM @NotNull @Override protected StateStorageManager createStateStorageManager() { - return new ModuleStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myModule); + return new ModuleStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myModule); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java index fd92723c6e95..2f15cd946c53 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.components.impl.stores; +import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.components.StateStorage; import com.intellij.openapi.components.StateStorage.SaveSession; import com.intellij.openapi.components.TrackingPathMacroSubstitutor; @@ -32,8 +33,8 @@ import java.util.List; import java.util.Set; public class ProjectWithModulesStoreImpl extends ProjectStoreImpl { - public ProjectWithModulesStoreImpl(@NotNull ProjectImpl project) { - super(project); + public ProjectWithModulesStoreImpl(@NotNull ProjectImpl project, @NotNull PathMacroManager pathMacroManager) { + super(project, pathMacroManager); } @Override diff --git a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java index 712e9e8bbc5b..505e78e2a09f 100644 --- a/platform/platform-api/src/com/intellij/ui/ScreenUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ScreenUtil.java @@ -69,14 +69,59 @@ public class ScreenUtil { } public static Shape getAllScreensShape() { - Rectangle[] rectangles = getAllScreenBounds(); + GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + if (devices.length == 0) { + return new Rectangle(); + } + if (devices.length == 1) { + return getScreenRectangle(devices[0]); + } Area area = new Area(); - for (Rectangle rectangle : rectangles) { - area.add(new Area(rectangle)); + for (GraphicsDevice device : devices) { + area.add(new Area(getScreenRectangle(device))); } return area; } + /** + * Returns the smallest rectangle that encloses a visible area of every screen. + * + * @return the smallest rectangle that encloses a visible area of every screen + */ + public static Rectangle getAllScreensRectangle() { + GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + if (devices.length == 0) { + return new Rectangle(); + } + if (devices.length == 1) { + return getScreenRectangle(devices[0]); + } + int minX = 0; + int maxX = 0; + int minY = 0; + int maxY = 0; + for (GraphicsDevice device : devices) { + Rectangle rectangle = getScreenRectangle(device); + int x = rectangle.x; + if (minX > x) { + minX = x; + } + x += rectangle.width; + if (maxX < x) { + maxX = x; + } + int y = rectangle.y; + if (minY > y) { + minY = y; + } + y += rectangle.height; + if (maxY < y) { + maxY = y; + } + } + return new Rectangle(minX, minY, maxX - minX, maxY - minY); + } + public static Rectangle getScreenRectangle(@NotNull Point p) { return getScreenRectangle(p.x, p.y); } diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index 658e08676729..2e24a9f70e01 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -19,8 +19,10 @@ import com.intellij.ide.BrowserUtil; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -37,6 +39,8 @@ import javax.swing.*; import javax.swing.border.Border; import javax.swing.tree.TreeCellRenderer; import java.awt.*; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -682,13 +686,24 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co } // 2. Waved effect if (attributes.isWaved()) { - if (attributes.getWaveColor() != null) { - g.setColor(attributes.getWaveColor()); - } - final int wavedAt = textBaseline + 1; - for (int x = offset; x <= offset + fragmentWidth; x += 4) { - UIUtil.drawLine(g, x, wavedAt, x + 2, wavedAt + 2); - UIUtil.drawLine(g, x + 3, wavedAt + 1, x + 4, wavedAt); + GraphicsConfig config = GraphicsUtil.setupAAPainting(g); + Stroke oldStroke = g.getStroke(); + try { + g.setStroke(new BasicStroke(.7F)); + if (attributes.getWaveColor() != null) { + g.setColor(attributes.getWaveColor()); + } + final int wavedAt = textBaseline + 1; + GeneralPath wavePath = new GeneralPath(PathIterator.WIND_EVEN_ODD); + wavePath.moveTo(offset, wavedAt); + for (int x = offset; x <= offset + fragmentWidth; x += 4) { + wavePath.lineTo(x + 2, wavedAt + 2); + wavePath.lineTo(x + 4, wavedAt); + } + g.draw(wavePath); + } finally { + config.restore(); + g.setStroke(oldStroke); } } // 3. Underline diff --git a/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java b/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java index f528bca961b3..e6c53ec7db6d 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/EditorOptionsTopHitProvider.java @@ -16,6 +16,7 @@ package com.intellij.ide.ui; import com.intellij.ide.ui.search.BooleanOptionDescription; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.containers.ContainerUtil; @@ -37,7 +38,18 @@ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider { ? "checkbox.enable.ctrl.mousewheel.changes.font.size.macos" : "checkbox.enable.ctrl.mousewheel.changes.font.size"), "IS_WHEEL_FONTCHANGE_ENABLED"), editor("Mouse: " + messageApp("checkbox.enable.drag.n.drop.functionality.in.editor"), "IS_DND_ENABLED"), - editor("Virtual Space: " + messageApp("checkbox.show.all.softwraps"), "IS_ALL_SOFTWRAPS_SHOWN"), + new EditorOptionDescription(null, messageApp("checkbox.show.softwraps.only.for.caret.line.action.text"), "preferences.editor") { + @Override + public boolean isOptionEnabled() { + return !EditorSettingsExternalizable.getInstance().isAllSoftWrapsShown(); + } + + @Override + public void setOptionState(boolean enabled) { + EditorSettingsExternalizable.getInstance().setAllSoftwrapsShown(!enabled); + fireUpdated(); + } + }, editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.after.end.of.line"), "IS_VIRTUAL_SPACE"), editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.inside.tabs"), "IS_CARET_INSIDE_TABS"), editor("Virtual Space: " + messageApp("checkbox.show.virtual.space.at.file.bottom"), "ADDITIONAL_PAGE_AT_BOTTOM"), diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ex/DecodeDefaultsUtil.java b/platform/platform-impl/src/com/intellij/openapi/application/ex/DecodeDefaultsUtil.java index f57812afca18..88f74955f8e5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/ex/DecodeDefaultsUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/ex/DecodeDefaultsUtil.java @@ -15,11 +15,12 @@ */ package com.intellij.openapi.application.ex; +import com.intellij.openapi.components.impl.stores.DirectoryStorageData; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.io.URLUtil; import gnu.trove.THashMap; -import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -32,46 +33,33 @@ public class DecodeDefaultsUtil { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.application.ex.DecodeDefaultsUtil"); private static final Map RESOURCE_CACHE = Collections.synchronizedMap(new THashMap()); - @NonNls private static final String XML_EXTENSION = ".xml"; - - public static URL getDefaults(Object requestor, final String componentResourcePath) { - if (RESOURCE_CACHE.containsKey(componentResourcePath)) { - return RESOURCE_CACHE.get(componentResourcePath); + public static URL getDefaults(Object requestor, @NotNull String componentResourcePath) { + URL url = RESOURCE_CACHE.get(componentResourcePath); + if (url == null) { + Class requestorClass = requestor.getClass(); + if (StringUtil.startsWithChar(componentResourcePath, '/')) { + url = requestorClass.getResource(componentResourcePath + DirectoryStorageData.DEFAULT_EXT); + } + else { + url = requestorClass.getResource('/' + ApplicationManagerEx.getApplicationEx().getName() + '/' + componentResourcePath + DirectoryStorageData.DEFAULT_EXT); + if (url == null) { + url = requestorClass.getResource('/' + componentResourcePath + DirectoryStorageData.DEFAULT_EXT); + } + } + RESOURCE_CACHE.put(componentResourcePath, url); } - - URL url = getDefaultsImpl(requestor, componentResourcePath); - RESOURCE_CACHE.put(componentResourcePath, url); return url; } - private static URL getDefaultsImpl(final Object requestor, final String componentResourcePath) { - boolean isPathAbsolute = StringUtil.startsWithChar(componentResourcePath, '/'); - if (isPathAbsolute) { - return requestor.getClass().getResource(componentResourcePath + XML_EXTENSION); - } - else { - return getResourceByRelativePath(requestor, componentResourcePath, XML_EXTENSION); - } - } - @Nullable - public static InputStream getDefaultsInputStream(Object requestor, final String componentResourcePath) { + public static InputStream getDefaultsInputStream(Object requestor, @NotNull String componentResourcePath) { try { final URL defaults = getDefaults(requestor, componentResourcePath); - return defaults != null ? URLUtil.openStream(defaults) : null; + return defaults == null ? null : URLUtil.openStream(defaults); } catch (IOException e) { LOG.error(e); return null; } } - - private static URL getResourceByRelativePath(Object requestor, final String componentResourcePath, String resourceExtension) { - String appName = ApplicationManagerEx.getApplicationEx().getName(); - URL result = requestor.getClass().getResource("/" + appName + "/" + componentResourcePath + resourceExtension); - if (result == null) { - result = requestor.getClass().getResource("/" + componentResourcePath + resourceExtension); - } - return result; - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java index 4d34e071993b..22ac3611ac82 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java @@ -18,7 +18,10 @@ package com.intellij.openapi.components.impl.stores; import com.intellij.application.options.PathMacrosImpl; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.impl.ApplicationImpl; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PathMacroManager; +import com.intellij.openapi.components.StateStorageOperation; +import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.components.TrackingPathMacroSubstitutor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.NamedJDOMExternalizable; import com.intellij.openapi.vfs.LocalFileSystem; @@ -33,13 +36,11 @@ import java.io.IOException; class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationStore { private static final Logger LOG = Logger.getInstance(ApplicationStoreImpl.class); - private static final String XML_EXTENSION = ".xml"; - private static final String DEFAULT_STORAGE_SPEC = StoragePathMacros.APP_CONFIG + "/" + PathManager.DEFAULT_OPTIONS_FILE_NAME + XML_EXTENSION; + private static final String DEFAULT_STORAGE_SPEC = StoragePathMacros.APP_CONFIG + "/" + PathManager.DEFAULT_OPTIONS_FILE_NAME + DirectoryStorageData.DEFAULT_EXT; private static final String ROOT_ELEMENT_NAME = "application"; private final ApplicationImpl myApplication; private final StateStorageManager myStateStorageManager; - private final DefaultsStateStorage myDefaultsStateStorage; private String myConfigPath; @@ -59,7 +60,7 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto @Override protected String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) { if (component instanceof NamedJDOMExternalizable) { - return StoragePathMacros.APP_CONFIG + "/" + ((NamedJDOMExternalizable)component).getExternalFileName() + XML_EXTENSION; + return StoragePathMacros.APP_CONFIG + '/' + ((NamedJDOMExternalizable)component).getExternalFileName() + DirectoryStorageData.DEFAULT_EXT; } else { return DEFAULT_STORAGE_SPEC; @@ -68,7 +69,7 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto @Override protected TrackingPathMacroSubstitutor getMacroSubstitutor(@NotNull final String fileSpec) { - if (fileSpec.equals(StoragePathMacros.APP_CONFIG + "/" + PathMacrosImpl.EXT_FILE_NAME + XML_EXTENSION)) return null; + if (fileSpec.equals(StoragePathMacros.APP_CONFIG + '/' + PathMacrosImpl.EXT_FILE_NAME + DirectoryStorageData.DEFAULT_EXT)) return null; return super.getMacroSubstitutor(fileSpec); } @@ -92,7 +93,6 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto } } }; - myDefaultsStateStorage = new DefaultsStateStorage(null); } @Override @@ -139,7 +139,7 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto @Nullable @Override - protected StateStorage getDefaultsStorage() { - return myDefaultsStateStorage; + protected PathMacroManager getPathMacroManagerForDefaults() { + return null; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/BaseFileConfigurableStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/BaseFileConfigurableStoreImpl.java index de61848337a7..a4db00970e4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/BaseFileConfigurableStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/BaseFileConfigurableStoreImpl.java @@ -15,7 +15,9 @@ */ package com.intellij.openapi.components.impl.stores; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PathMacroManager; +import com.intellij.openapi.components.PathMacroSubstitutor; +import com.intellij.openapi.components.StateStorageException; import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.util.SmartList; import org.jdom.Element; @@ -34,18 +36,11 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl { private static final List ourConversionProblemsStorage = new SmartList(); - private final ComponentManager myComponentManager; - private final DefaultsStateStorage myDefaultsStateStorage; private StateStorageManager myStateStorageManager; + protected final PathMacroManager myPathMacroManager; - protected BaseFileConfigurableStoreImpl(@NotNull ComponentManager componentManager) { - myComponentManager = componentManager; - myDefaultsStateStorage = new DefaultsStateStorage(PathMacroManager.getInstance(myComponentManager)); - } - - @NotNull - public ComponentManager getComponentManager() { - return myComponentManager; + protected BaseFileConfigurableStoreImpl(@NotNull PathMacroManager pathMacroManager) { + myPathMacroManager = pathMacroManager; } protected static class BaseStorageData extends StorageData { @@ -115,10 +110,10 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl { return (BaseStorageData)getMainStorage().getStorageData(); } - @Nullable + @NotNull @Override - protected StateStorage getDefaultsStorage() { - return myDefaultsStateStorage; + protected final PathMacroManager getPathMacroManagerForDefaults() { + return myPathMacroManager; } @NotNull diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java index a1ec60a41c54..72e4cea994d4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java @@ -16,6 +16,7 @@ package com.intellij.openapi.components.impl.stores; import com.intellij.openapi.application.*; +import com.intellij.openapi.application.ex.DecodeDefaultsUtil; import com.intellij.openapi.components.*; import com.intellij.openapi.components.StateStorage.SaveSession; import com.intellij.openapi.components.impl.ComponentManagerImpl; @@ -29,6 +30,7 @@ import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; +import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtilRt; @@ -37,12 +39,16 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.SmartHashSet; import com.intellij.util.messages.MessageBus; +import com.intellij.util.xmlb.JDOMXIncluder; import gnu.trove.THashMap; import org.jdom.Element; +import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.lang.reflect.Type; +import java.net.URL; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; @@ -52,9 +58,6 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { private final Map myComponents = Collections.synchronizedMap(new THashMap()); private final List mySettingsSavingComponents = new CopyOnWriteArrayList(); - @Nullable - protected abstract StateStorage getDefaultsStorage(); - @Override public void initComponent(@NotNull Object component, boolean service) { if (component instanceof SettingsSavingComponent) { @@ -158,7 +161,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { return; } - Element element = getJdomState(component, componentName, stateStorage); + Element element = stateStorage.getState(component, componentName, Element.class, null); if (element == null) { return; } @@ -185,30 +188,18 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { myComponents.put(componentName, component); } - private void loadJdomDefaults(@NotNull Object component, @NotNull String componentName) { + private void loadJdomDefaults(@NotNull JDOMExternalizable component, @NotNull String componentName) { try { - StateStorage defaultsStorage = getDefaultsStorage(); - if (defaultsStorage == null) { - return; + Element defaultState = getDefaultState(component, componentName, Element.class); + if (defaultState != null) { + component.readExternal(defaultState); } - - Element defaultState = getJdomState(component, componentName, defaultsStorage); - if (defaultState == null) { - return; - } - - ((JDOMExternalizable)component).readExternal(defaultState); } catch (Exception e) { LOG.error("Cannot load defaults for " + component.getClass(), e); } } - @Nullable - private static Element getJdomState(final Object component, @NotNull String componentName, @NotNull StateStorage defaultsStorage) { - return defaultsStorage.getState(component, componentName, Element.class, null); - } - @Nullable protected Project getProject() { return null; @@ -239,11 +230,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { } Class stateClass = getComponentStateClass(component); - T state = null; - StateStorage defaultsStorage = getDefaultsStorage(); - if (defaultsStorage != null) { - state = defaultsStorage.getState(component, name, stateClass, null); - } + T state = getDefaultState(component, name, stateClass); Storage[] storageSpecs = getComponentStorageSpecs(component, stateSpec, StateStorageOperation.READ); for (Storage storageSpec : storageSpecs) { @@ -264,6 +251,34 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { return name; } + @Nullable + protected abstract PathMacroManager getPathMacroManagerForDefaults(); + + @Nullable + protected T getDefaultState(@NotNull Object component, @NotNull String componentName, @NotNull final Class stateClass) { + URL url = DecodeDefaultsUtil.getDefaults(component, componentName); + if (url == null) { + return null; + } + + try { + Element documentElement = JDOMXIncluder.resolve(JDOMUtil.loadDocument(url), url.toExternalForm()).detachRootElement(); + + PathMacroManager pathMacroManager = getPathMacroManagerForDefaults(); + if (pathMacroManager != null) { + pathMacroManager.expandPaths(documentElement); + } + + return DefaultStateSerializer.deserializeState(documentElement, stateClass, null); + } + catch (IOException e) { + throw new StateStorageException("Error loading state from " + url, e); + } + catch (JDOMException e) { + throw new StateStorageException("Error loading state from " + url, e); + } + } + @NotNull private static Class getComponentStateClass(@NotNull final PersistentStateComponent persistentStateComponent) { final Class persistentStateComponentClass = PersistentStateComponent.class; diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java index 6cd6ea590b9d..2ffbd3da555d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java @@ -31,17 +31,14 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -//todo: extends from base store class public class DefaultProjectStoreImpl extends ProjectStoreImpl { - @Nullable private final Element myElement; private final ProjectManagerImpl myProjectManager; @NonNls private static final String ROOT_TAG_NAME = "defaultProject"; - public DefaultProjectStoreImpl(@NotNull ProjectImpl project, @NotNull ProjectManagerImpl projectManager) { - super(project); + public DefaultProjectStoreImpl(@NotNull ProjectImpl project, @NotNull ProjectManagerImpl projectManager, @NotNull PathMacroManager pathMacroManager) { + super(project, pathMacroManager); myProjectManager = projectManager; - myElement = projectManager.getDefaultProjectRootElement(); } @Nullable @@ -53,21 +50,12 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl { @NotNull @Override protected StateStorageManager createStateStorageManager() { - Element _d = null; - - if (myElement != null) { - myElement.detach(); - _d = myElement; - } - - ComponentManager componentManager = getComponentManager(); - final Element element = _d; - final XmlElementStorage storage = new XmlElementStorage("", RoamingType.DISABLED, PathMacroManager.getInstance(componentManager).createTrackingSubstitutor(), + final XmlElementStorage storage = new XmlElementStorage("", RoamingType.DISABLED, myPathMacroManager.createTrackingSubstitutor(), ROOT_TAG_NAME, null) { @Override @Nullable protected Element loadLocalData() { - return element; + return myProjectManager.getDefaultProjectRootElement(); } @Override @@ -176,9 +164,10 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl { } @Override - public void load() throws IOException, StateStorageException { - if (myElement == null) return; - super.load(); + public void load() throws IOException { + if (myProjectManager.getDefaultProjectRootElement() != null) { + super.load(); + } } private static class MyExternalizationSession implements StateStorageManager.ExternalizationSession { diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultsStateStorage.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultsStateStorage.java deleted file mode 100644 index a8170ea9fbfa..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultsStateStorage.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2000-2014 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.openapi.components.impl.stores; - -import com.intellij.openapi.application.ex.DecodeDefaultsUtil; -import com.intellij.openapi.components.PathMacroManager; -import com.intellij.openapi.components.StateStorage; -import com.intellij.openapi.components.StateStorageException; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.xmlb.JDOMXIncluder; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.net.URL; -import java.util.Collection; -import java.util.Set; - -class DefaultsStateStorage implements StateStorage { - private final PathMacroManager myPathMacroManager; - - public DefaultsStateStorage(@Nullable final PathMacroManager pathMacroManager) { - myPathMacroManager = pathMacroManager; - } - - @Nullable - private Element getState(final Object component, final String componentName) throws StateStorageException { - final URL url = DecodeDefaultsUtil.getDefaults(component, componentName); - if (url == null) { - return null; - } - - try { - Document document = JDOMUtil.loadDocument(url); - document = JDOMXIncluder.resolve(document, url.toExternalForm()); - final Element documentElement = document.detachRootElement(); - - if (myPathMacroManager != null) { - myPathMacroManager.expandPaths(documentElement); - } - - return documentElement; - } - catch (IOException e) { - throw new StateStorageException("Error loading state from " + url, e); - } - catch (JDOMException e) { - throw new StateStorageException("Error loading state from " + url, e); - } - } - - @Override - @Nullable - public T getState(final Object component, @NotNull final String componentName, @NotNull final Class stateClass, @Nullable final T mergeInto) { - return DefaultStateSerializer.deserializeState(getState(component, componentName), stateClass, mergeInto); - } - - @Override - public boolean hasState(@Nullable final Object component, @NotNull final String componentName, final Class aClass, final boolean reloadData) { - return DecodeDefaultsUtil.getDefaults(component, componentName) != null; - } - - @Override - @Nullable - public ExternalizationSession startExternalization() { - return null; - } - - @Override - public void analyzeExternalChangesAndUpdateIfNeed(@NotNull Collection changedFiles, @NotNull Set result) { - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 08572a0599cc..404512c9f34a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -63,8 +63,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject private StorageScheme myScheme = StorageScheme.DEFAULT; private String myPresentableUrl; - ProjectStoreImpl(@NotNull ProjectImpl project) { - super(project); + ProjectStoreImpl(@NotNull ProjectImpl project, @NotNull PathMacroManager pathMacroManager) { + super(pathMacroManager); myProject = project; } @@ -359,16 +359,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject } @Override - public void loadProjectFromTemplate(@NotNull final ProjectImpl defaultProject) { - XmlElementStorage stateStorage = getProjectFileStorage(); - + public void loadProjectFromTemplate(@NotNull ProjectImpl defaultProject) { defaultProject.save(); - final IProjectStore projectStore = defaultProject.getStateStore(); - assert projectStore instanceof DefaultProjectStoreImpl; - DefaultProjectStoreImpl defaultProjectStore = (DefaultProjectStoreImpl)projectStore; - final Element element = defaultProjectStore.getStateCopy(); + + Element element = ((DefaultProjectStoreImpl)defaultProject.getStateStore()).getStateCopy(); if (element != null) { - stateStorage.setDefaultState(element); + getProjectFileStorage().setDefaultState(element); } } @@ -387,7 +383,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject @NotNull @Override protected StateStorageManager createStateStorageManager() { - return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject); + return new ProjectStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myProject); } static class ProjectStorageData extends BaseStorageData { diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/FragmentBoundRenderer.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/FragmentBoundRenderer.java index b179b7d4dd0a..f2ac5b7545cc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/FragmentBoundRenderer.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/highlighting/FragmentBoundRenderer.java @@ -155,25 +155,36 @@ public class FragmentBoundRenderer implements LineMarkerRenderer, LineSeparatorR final boolean mirrorX, final int mirrorSize) { final Iterator> iterator = points.iterator(); assert iterator.hasNext(); - final Convertor c = new Convertor() { - @Override - public Integer convert(Integer o) { - final int val = x1 + o - subtractX; - if (mirrorX) { - return mirrorSize - val; - } - return val; - } - }; + + int[] xPoints = new int[points.size()]; + int[] yPoints1 = new int[points.size()]; + int[] yPoints2 = new int[points.size()]; + int n = 0; + Couple previous = iterator.next(); while (iterator.hasNext()) { final Couple next = iterator.next(); - UIUtil.drawLine(g, c.convert(previous.getFirst()), y + offset + previous.getSecond() - myLineHeight/2, c.convert(next.getFirst()), - y + offset + next.getSecond() - myLineHeight/2); - UIUtil.drawLine(g, c.convert(previous.getFirst()), y - offset + previous.getSecond() - myLineHeight/2, c.convert(next.getFirst()), - y - offset + next.getSecond() - myLineHeight/2); + + xPoints[n] = convert(previous.getFirst(), x1, subtractX, mirrorX, mirrorSize); + yPoints1[n] = y + offset + previous.getSecond() - myLineHeight / 2; + yPoints2[n] = y - offset + previous.getSecond() - myLineHeight / 2; + n++; previous = next; } + xPoints[n] = convert(previous.getFirst(), x1, subtractX, mirrorX, mirrorSize); + yPoints1[n] = y + offset + previous.getSecond() - myLineHeight / 2; + yPoints2[n] = y - offset + previous.getSecond() - myLineHeight / 2; + + g.drawPolyline(xPoints, yPoints1, points.size()); + g.drawPolyline(xPoints, yPoints2, points.size()); + } + + private static int convert(int value, int x1, int subtractX, boolean mirrorX, int mirrorSize) { + final int val = x1 + value - subtractX; + if (mirrorX) { + return mirrorSize - val; + } + return val; } private static class ShoeneLine { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index 4988155eea4b..042730508909 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -94,6 +94,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt private ProjectImpl myDefaultProject; // Only used asynchronously in save and dispose, which itself are synchronized. @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) private Element myDefaultProjectRootElement; // Only used asynchronously in save and dispose, which itself are synchronized. + private boolean myDefaultProjectConfigurationChanged; private final List myOpenProjects = new ArrayList(); private Project[] myOpenProjectsArrayCache = {}; @@ -257,6 +258,18 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt } } + File projectFile = new File(filePath); + if (projectFile.isFile()) { + FileUtil.delete(projectFile); + } + else { + File[] files = new File(projectFile, Project.DIRECTORY_STORE_FOLDER).listFiles(); + if (files != null) { + for (File file : files) { + FileUtil.delete(file); + } + } + } ProjectImpl project = createProject(projectName, filePath, false, optimiseTestLoadSpeed); try { initProject(project, useDefaultProjectSettings ? (ProjectImpl)getDefaultProject() : null); @@ -387,7 +400,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt try { myDefaultProject = createProject(null, "", true, ApplicationManager.getApplication().isUnitTestMode()); initProject(myDefaultProject, null); - myDefaultProjectRootElement = null; } catch (Throwable t) { PluginManager.processException(t); @@ -990,7 +1002,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt myDefaultProject.save(); } - if (myDefaultProjectRootElement == null) { + if (!myDefaultProjectConfigurationChanged) { // we are not ready to save return null; } @@ -1007,10 +1019,12 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt if (myDefaultProjectRootElement != null) { myDefaultProjectRootElement.detach(); } + myDefaultProjectConfigurationChanged = false; } public void setDefaultProjectRootElement(@NotNull Element defaultProjectRootElement) { myDefaultProjectRootElement = defaultProjectRootElement; + myDefaultProjectConfigurationChanged = true; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 6a326f1a70d4..de1790b6dee2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -225,7 +225,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements NamedCom @Override public final Rectangle getScreenBounds() { - return ScreenUtil.getAllScreensShape().getBounds(); + return ScreenUtil.getAllScreensRectangle(); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java index 68482d0d432a..addbc4f46f41 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java @@ -109,9 +109,11 @@ public class NewRecentProjectPanel extends RecentProjectPanel { closeButtonCell.gridx = 1; closeButtonCell.gridy = 0; + closeButtonCell.anchor = GridBagConstraints.FIRST_LINE_END; + closeButtonCell.insets = new Insets(7, 7, 7, 7); closeButtonCell.gridheight = 2; - closeButtonCell.anchor = GridBagConstraints.WEST; + //closeButtonCell.anchor = GridBagConstraints.WEST; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java index f9a855ae5116..fd15deb7b588 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java @@ -47,7 +47,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.*; @@ -58,19 +57,38 @@ public class RecentProjectPanel extends JPanel { protected final UniqueNameBuilder myPathShortener; protected AnAction removeRecentProjectAction; private int myHoverIndex = -1; + private static final int closeButtonInset = 7; + private Icon currentIcon = AllIcons.Welcome.RemoveRecentProject; private final JPanel myCloseButtonForEditor = new JPanel() { { - setPreferredSize(new Dimension(AllIcons.General.BalloonClose.getIconWidth(), AllIcons.General.BalloonClose.getIconHeight())); + setPreferredSize(new Dimension(currentIcon.getIconWidth(), currentIcon.getIconHeight())); setOpaque(true); } @Override protected void paintComponent(Graphics g) { - AllIcons.General.BalloonClose.paintIcon(this, g, 0, 0); + currentIcon.paintIcon(this, g, 0, 0); } }; + + private boolean rectInListCoordinatesContains(Rectangle listCellBounds, Point p) { + + int realCloseButtonInset = (UIUtil.isRetina(myList.getGraphicsConfiguration().getDevice())) ? + closeButtonInset * 2 : closeButtonInset; + + Rectangle closeButtonRect = new Rectangle(myCloseButtonForEditor.getX() - realCloseButtonInset, + myCloseButtonForEditor.getY() - realCloseButtonInset, + myCloseButtonForEditor.getWidth() + realCloseButtonInset * 2, + myCloseButtonForEditor.getHeight() + realCloseButtonInset * 2); + + Rectangle rectInListCoordinates = new Rectangle(new Point(closeButtonRect.x + listCellBounds.x, + closeButtonRect.y + listCellBounds.y), + closeButtonRect.getSize()); + return rectInListCoordinates.contains(p); + } + public RecentProjectPanel(WelcomeScreen screen) { super(new BorderLayout()); @@ -93,12 +111,7 @@ public class RecentProjectPanel extends JPanel { Rectangle cellBounds = myList.getCellBounds(selectedIndex, selectedIndex); if (cellBounds.contains(event.getPoint())) { Object selection = myList.getSelectedValue(); - - Rectangle closeButtonRect = myCloseButtonForEditor.getBounds(); - - Rectangle rectInListCoordinates = new Rectangle(new Point(closeButtonRect.x + cellBounds.x, closeButtonRect.y + cellBounds.y), closeButtonRect.getSize()); - - if (Registry.is("removable.welcome.screen.projects") && rectInListCoordinates.contains(event.getPoint())) { + if (Registry.is("removable.welcome.screen.projects") && rectInListCoordinatesContains(cellBounds, event.getPoint())) { removeRecentProjectAction.actionPerformed(null); } else if (selection != null) { ((AnAction)selection).actionPerformed( @@ -203,11 +216,16 @@ public class RecentProjectPanel extends JPanel { int index = myList.locationToIndex(point); myList.setSelectedIndex(index); - final Rectangle bounds = myList.getCellBounds(index, index); - if (bounds != null && bounds.contains(point)) { + final Rectangle cellBounds = myList.getCellBounds(index, index); + if (cellBounds != null && cellBounds.contains(point)) { myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + if (rectInListCoordinatesContains(cellBounds, point)) { + currentIcon = AllIcons.Welcome.RemoveRecentProjectHover; + } else { + currentIcon = AllIcons.Welcome.RemoveRecentProject; + } myHoverIndex = index; - myList.repaint(bounds); + myList.repaint(cellBounds); } else { myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); @@ -223,6 +241,7 @@ public class RecentProjectPanel extends JPanel { @Override public void mouseExited(MouseEvent e) { myHoverIndex = -1; + currentIcon = AllIcons.Welcome.RemoveRecentProject; myList.repaint(); } }; @@ -261,7 +280,7 @@ public class RecentProjectPanel extends JPanel { private static class MyList extends JBList { private final Dimension mySize; - private MyList(Dimension size, @NotNull Object... listData) { + private MyList(Dimension size, @NotNull Object ... listData) { super(listData); mySize = size; setEmptyText(" No Project Open Yet "); diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java index ce24352c953f..10af58c551c6 100644 --- a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java +++ b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java @@ -301,10 +301,18 @@ public abstract class AbstractExpandableItemsHandler visMaxY) return null; + + int cellMaxX = cellBounds.x + cellBounds.width; + int visMaxX = visibleRect.x + visibleRect.width; + + Point location = new Point(visMaxX, cellBounds.y); + SwingUtilities.convertPointToScreen(location, myComponent); + + Rectangle screen = !Registry.is("ide.expansion.hints.on.all.screens") + ? ScreenUtil.getScreenRectangle(location) + : ScreenUtil.getAllScreensRectangle(); + + int borderWidth = isPaintBorder() ? 1 : 0; + int width = Math.min(screen.width + screen.x - location.x - borderWidth, cellMaxX - visMaxX); int height = cellBounds.height; if (width <= 0 || height <= 0) return null; - if (cellBounds.y < visibleRect.y) return null; - if (cellBounds.y + cellBounds.height > visibleRect.y + visibleRect.height) return null; Dimension size = getImageSize(width, height); myImage = UIUtil.createImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); @@ -401,16 +394,15 @@ public abstract class AbstractExpandableItemsHandler 0) { + border = new CustomLineBorder(getBorderColor(), borderWidth, 0, borderWidth, borderWidth); + location.y -= borderWidth; + size.width += borderWidth; + size.height += borderWidth + borderWidth; } g.dispose(); diff --git a/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java b/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java index 86318c465072..d27e89ce2019 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java +++ b/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java @@ -483,7 +483,7 @@ public abstract class JBListTable { * @return whether this row animation is complete */ public boolean doAnimationStep(long currentTime) { - if (myTable.getRowCount() >= myRow) return true; + if (myRow >= myTable.getRowCount()) return true; int currentRowHeight = myTable.getRowHeight(myRow); int resizeAbs = (int) (RESIZE_AMOUNT_PER_STEP * ((currentTime - myLastUpdateTime) / (double)ANIMATION_STEP_MILLIS)); diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 6a1baadbfc2f..29121a5e3a0c 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -390,7 +390,8 @@ group.soft.wraps=Soft Wraps checkbox.use.soft.wraps.at.editor=Use soft wraps in editor checkbox.use.soft.wraps.at.console=Use soft wraps in console checkbox.use.custom.soft.wraps.indent=Use original line's indent for wrapped parts. Additional shift: -checkbox.show.softwraps.only.for.caret.line=Show soft wrap symbols only for current line +checkbox.show.softwraps.only.for.caret.line=Show soft wraps for current line only +checkbox.show.softwraps.only.for.caret.line.action.text=Soft Wraps: Show for current line only group.virtual.space=Virtual Space checkbox.allow.placement.of.caret.after.end.of.line=Allow placement of caret after end of line checkbox.allow.placement.of.caret.inside.tabs=Allow placement of caret inside tabs diff --git a/platform/platform-resources-en/src/messages/CodeEditorBundle.properties b/platform/platform-resources-en/src/messages/CodeEditorBundle.properties index 82a29b7c5435..a1c47c6de185 100644 --- a/platform/platform-resources-en/src/messages/CodeEditorBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeEditorBundle.properties @@ -52,11 +52,12 @@ print.header.alignment.combobox=Alignment print.apply.button=A&pply print.progress=Printing... print.header.default.line.1=File - $FILE$ -print.header.default.line.2=Page $PAGE$ +print.header.default.line.2=Page $PAGE$ of $TOTALPAGES$ print.header.placement.header=Header print.header.placement.footer=Footer print.header.alignment.left=Left print.header.alignment.center=Center print.header.alignment.right=Right -print.file.page.progress=Printing {0}. Page {1}... +print.file.calculating.number.of.pages.progress=Calculating number of pages... +print.file.page.progress=Printing {0}. Page {1} of {2} file.not.found=File not found: {0} diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 2cc34d3f5082..8f4fa6e21aaf 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -131,6 +131,7 @@ title.select.template=Select Template label.name=Name: label.extension=Extension: title.file.templates=File and Code Templates +title.edit.file.template=Edit File Template checkbox.reformat.according.to.style=Reformat according to style label.description=Description item.file.templates=File templates diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.java index bb17ec43dd8b..58c06e218791 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ApplicationStoreTest.java @@ -214,7 +214,7 @@ public class ApplicationStoreTest extends LightPlatformLangTestCase { @Nullable @Override - protected StateStorage getDefaultsStorage() { + protected PathMacroManager getPathMacroManagerForDefaults() { return null; } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreBaseTestCase.java b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreBaseTestCase.java index 5d566ec77023..253700c492a5 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreBaseTestCase.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreBaseTestCase.java @@ -18,14 +18,22 @@ package com.intellij.openapi.components.impl; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.util.JDOMBuilder; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.testFramework.PlatformLangTestCase; +import java.io.File; import java.io.UnsupportedEncodingException; public abstract class ProjectStoreBaseTestCase extends PlatformLangTestCase { + @Override + protected Project doCreateProject(File projectFile) throws Exception { + return ProjectManagerEx.getInstanceEx().loadProject(projectFile.getAbsolutePath()); + } + protected byte[] getIprFileContent() throws UnsupportedEncodingException { final String iprContent = JDOMUtil.writeDocument( JDOMBuilder.document(JDOMBuilder.tag("project", diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index 03e22b45699a..9cf09ff14739 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -101,6 +101,7 @@ predefined.configuration.class.implements.two.interfaces=class implementing two predefined.configuration.bean.info.classes=Bean info classes predefined.configuration.all.expressions.of.some.type=all expressions of some type predefined.configuration.variables.of.generic.types=variables of generic types +predefined.configuration.diamond.operators=diamond operators predefined.configuration.comments=comments predefined.configuration.fields_variables.with.given.name.pattern.updated=fields/variables with given name pattern updated predefined.configuration.trys=try's @@ -145,6 +146,7 @@ predefined.configuration.packagelocal.fields.of.the.class=package local fields o predefined.configuration.classes=classes predefined.configuration.new.expressions=new expressions predefined.configuration.lambdas=lambdas +predefined.configuration.method.references=method references # edit variable constraint dialog options invalid.regular.expression=Invalid regular expression diff --git a/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java b/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java index 400744bcc9e0..b7e33f6d6ef2 100644 --- a/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java +++ b/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java @@ -15,7 +15,6 @@ */ package com.intellij.projectView; -import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.ide.projectView.impl.AbstractProjectTreeStructure; import com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane; import com.intellij.openapi.Disposable; @@ -97,8 +96,4 @@ public class TestProjectTreeStructure extends AbstractProjectTreeStructure imple @Override public void dispose() { } - - public String getProjectFileRepresentation() { - return " " + myProject.getName() + ProjectFileType.DOT_DEFAULT_EXTENSION + "\n"; - } } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index cd86bd76f7f3..9f8a8badc36a 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -121,6 +121,7 @@ ide.tooltip.autoDismissDeadZone=300 ide.balloon.shadowEnabled=true ide.balloon.shadow.size=15 ide.expansion.hints.enabled=true +ide.expansion.hints.on.all.screens=false ide.register.bundled.fonts=true ide.register.bundled.fonts.description=Disables automatic registration of bundled fonts: SourceCodePro, Inconsolata @@ -515,7 +516,7 @@ check.power.supply.for.mbp.description=Check for discrete video card and power s force.subpixel.hinting=false force.subpixel.hinting.description=Force using sub-pixel antialiasing -lcd.contrast.value=140 +lcd.contrast.value=100 lcd.contrast.value.description=Set LCD text contrast value from 100 to 250 removable.welcome.screen.projects=false diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index 2e3233570e37..abb675c2c6c2 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -1185,6 +1185,9 @@ public class AllIcons { public static final Icon OpenProject = IconLoader.getIcon("/welcome/openProject.png"); // 16x16 public static final Icon Register = IconLoader.getIcon("/welcome/register.png"); // 32x32 + public static final Icon RemoveRecentProject = IconLoader.getIcon("/welcome/project/remove.png"); // 10x10 + public static final Icon RemoveRecentProjectHover = IconLoader.getIcon("/welcome/project/remove-hover.png"); // 10x10 + } public static class Xml { diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 3baa8c859b77..98a4c350a07c 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -385,6 +385,14 @@ public class UIUtil { } } + public static boolean isRetina (GraphicsDevice device) { + if (SystemInfo.isMac && SystemInfo.isJavaVersionAtLeast("1.7")) { + return DetectRetinaKit.isOracleMacRetinaDevice(device); + } else { + return isRetina(); + } + } + //public static boolean isMacRetina(Graphics2D g) { // return DetectRetinaKit.isMacRetina(g); //} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/HtmlTagCanBeJavadocTagInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/HtmlTagCanBeJavadocTagInspection.java index bfa26c048ea8..b561e32d51a9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/HtmlTagCanBeJavadocTagInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/javadoc/HtmlTagCanBeJavadocTagInspection.java @@ -109,7 +109,7 @@ public class HtmlTagCanBeJavadocTagInspection extends BaseInspection { } private static void appendElementText(String text, int startOffset, int endOffset, StringBuilder out) { - if (out.length() == 6 && endOffset - startOffset > 0 && !Character.isWhitespace(text.charAt(startOffset))) { + if (out.length() == "{@code".length() && endOffset - startOffset > 0 && !Character.isWhitespace(text.charAt(startOffset))) { out.append(' '); } out.append(text, startOffset, endOffset); diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java index e401deeb4f30..612255f42450 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -161,7 +161,7 @@ public class ClassWriter { DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, node); int startLine = tracer != null ? tracer.getCurrentSourceLine() : 0; - BytecodeMappingTracer dummy_tracer = new BytecodeMappingTracer(); + BytecodeMappingTracer dummy_tracer = new BytecodeMappingTracer(startLine); try { // last minute processing @@ -184,6 +184,8 @@ public class ClassWriter { // fields boolean enumFields = false; + dummy_tracer.incrementCurrentSourceLine(buffer.countLines(start_class_def)); + for (StructField fd : cl.getFields()) { boolean hide = fd.isSynthetic() && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) || wrapper.getHiddenMembers().contains(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor())); @@ -193,6 +195,7 @@ public class ClassWriter { if (isEnum) { if (enumFields) { buffer.append(',').appendLineSeparator(); + dummy_tracer.incrementCurrentSourceLine(); } enumFields = true; } @@ -200,6 +203,7 @@ public class ClassWriter { buffer.append(';'); buffer.appendLineSeparator(); buffer.appendLineSeparator(); + dummy_tracer.incrementCurrentSourceLine(2); enumFields = false; } @@ -210,6 +214,7 @@ public class ClassWriter { if (enumFields) { buffer.append(';').appendLineSeparator(); + dummy_tracer.incrementCurrentSourceLine(); } // FIXME: fields don't matter at the moment @@ -383,6 +388,7 @@ public class ClassWriter { } private void fieldToJava(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent, BytecodeMappingTracer tracer) { + int start = buffer.length(); boolean isInterface = cl.hasModifier(CodeConstants.ACC_INTERFACE); boolean isDeprecated = fd.getAttributes().containsKey("Deprecated"); boolean isEnum = fd.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); @@ -430,6 +436,8 @@ public class ClassWriter { buffer.append(fd.getName()); + tracer.incrementCurrentSourceLine(buffer.countLines(start)); + Exprent initializer; if (fd.hasModifier(CodeConstants.ACC_STATIC)) { initializer = wrapper.getStaticFieldInitializers().getWithKey(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor())); @@ -461,6 +469,7 @@ public class ClassWriter { if (!isEnum) { buffer.append(";").appendLineSeparator(); + tracer.incrementCurrentSourceLine(); } } @@ -771,6 +780,8 @@ public class ClassWriter { } } + tracer.incrementCurrentSourceLine(buffer.countLines(start_index_method)); + if ((flags & (CodeConstants.ACC_ABSTRACT | CodeConstants.ACC_NATIVE)) != 0) { // native or abstract method (explicit or interface) if (isAnnotation) { StructAnnDefaultAttribute attr = (StructAnnDefaultAttribute)mt.getAttributes().getWithKey("AnnotationDefault"); @@ -794,12 +805,12 @@ public class ClassWriter { buffer.setCurrentLine(lineNumberTable.getFirstLine() - 1); } buffer.append('{').appendLineSeparator(); + tracer.incrementCurrentSourceLine(); RootStatement root = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()).root; if (root != null && !methodWrapper.decompiledWithErrors) { // check for existence try { - tracer.incrementCurrentSourceLine(buffer.countLines(start_index_method)); int startLine = tracer.getCurrentSourceLine(); TextBuffer code = root.toJava(indent + 1, tracer); diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/TextBuffer.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/TextBuffer.java index 2016f08b306b..93e51939507a 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/TextBuffer.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/TextBuffer.java @@ -307,7 +307,12 @@ public class TextBuffer { if (lineMapping.length > 0) { myLineMapping = new HashMap(); for (int i = 0; i < lineMapping.length; i+=2) { - myLineMapping.put(lineMapping[i+1], lineMapping[i]); + int key = lineMapping[i + 1]; + int value = lineMapping[i]; + Integer existing = myLineMapping.get(key); + if (existing == null || value < existing) { + myLineMapping.put(key, value); + } } } } diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java index 70ea2bc2b575..26cec6227c94 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/VarExprent.java @@ -85,6 +85,7 @@ public class VarExprent extends Exprent { if (classDef) { ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(varType.value); new ClassWriter().classToJava(child, buffer, indent, tracer); + tracer.incrementCurrentSourceLine(buffer.countLines()); } else { String name = null; diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java index 1c028d018e36..4a5eb1333703 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java @@ -256,14 +256,13 @@ public class IfStatement extends Statement { elseif = true; } else { - BytecodeMappingTracer else_tracer = new BytecodeMappingTracer(tracer.getCurrentSourceLine()); + BytecodeMappingTracer else_tracer = new BytecodeMappingTracer(tracer.getCurrentSourceLine() + 1); TextBuffer content = ExprProcessor.jmpWrapper(elsestat, indent + 1, false, else_tracer); if (content.length() > 0) { buf.appendIndent(indent).append("} else {").appendLineSeparator(); - else_tracer.shiftSourceLines(1); - tracer.setCurrentSourceLine(else_tracer.getCurrentSourceLine() + 1); + tracer.setCurrentSourceLine(else_tracer.getCurrentSourceLine()); tracer.addTracer(else_tracer); buf.append(content); diff --git a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/BytecodeToSourceMappingTest.java b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/BytecodeToSourceMappingTest.java deleted file mode 100644 index d84dd99bad4f..000000000000 --- a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/BytecodeToSourceMappingTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2014 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 org.jetbrains.java.decompiler; - -import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -public class BytecodeToSourceMappingTest extends SingleClassesTestBase { - @Override - protected Map getDecompilerOptions() { - return new HashMap() {{ - put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1"); - put(IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1"); - }}; - } - - @Test public void testSimpleBytecodeMapping() { doTest("pkg/TestClassSimpleBytecodeMapping"); } - @Test public void testSynchronizedMapping() { doTest("pkg/TestSynchronizedMapping"); } - @Test public void testAbstractMethods() { doTest("pkg/TestAbstractMethods"); } -} diff --git a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java index c1b36def4c82..8a51c728cb4a 100644 --- a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -15,9 +15,21 @@ */ package org.jetbrains.java.decompiler; +import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; + public class SingleClassesTest extends SingleClassesTestBase { + @Override + protected Map getDecompilerOptions() { + return new HashMap() {{ + put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1"); + put(IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1"); + }}; + } + @Test public void testClassFields() { doTest("pkg/TestClassFields"); } @Test public void testClassLambda() { doTest("pkg/TestClassLambda"); } @Test public void testClassLoop() { doTest("pkg/TestClassLoop"); } @@ -39,4 +51,10 @@ public class SingleClassesTest extends SingleClassesTestBase { @Test public void testTryCatchFinally() { doTest("pkg/TestTryCatchFinally"); } @Test public void testAmbiguousCall() { doTest("pkg/TestAmbiguousCall"); } @Test public void testAmbiguousCallWithDebugInfo() { doTest("pkg/TestAmbiguousCallWithDebugInfo"); } + @Test public void testSimpleBytecodeMapping() { doTest("pkg/TestClassSimpleBytecodeMapping"); } + @Test public void testSynchronizedMapping() { doTest("pkg/TestSynchronizedMapping"); } + @Test public void testAbstractMethods() { doTest("pkg/TestAbstractMethods"); } + @Test public void testLocalClass() { doTest("pkg/TestLocalClass"); } + @Test public void testAnonymousClass() { doTest("pkg/TestAnonymousClass"); } + @Test public void testThrowException() { doTest("pkg/TestThrowException"); } } diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$1.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$1.class new file mode 100644 index 000000000000..ff5e5878409d Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$1.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$2.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$2.class new file mode 100644 index 000000000000..536f320ed1c9 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$2.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$3.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$3.class new file mode 100644 index 000000000000..cc8d377c9534 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$3.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$4.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$4.class new file mode 100644 index 000000000000..3ee643664627 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$4.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$I.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$I.class new file mode 100644 index 000000000000..48eb4edc1bd2 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$I.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner$1.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner$1.class new file mode 100644 index 000000000000..798b358a7b36 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner$1.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner.class new file mode 100644 index 000000000000..2b3d4639c26b Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass$Inner.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass.class new file mode 100644 index 000000000000..a849cd60ab4c Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestAnonymousClass.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByAnno.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByAnno.class index dca17055a9f3..cb8f565061da 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByAnno.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByAnno.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByComment.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByComment.class index c1da53c08db1..d6013ce5aa3d 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByComment.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations$ByComment.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations.class index 29924d2b61a8..ab0eb0eb723d 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestDeprecations.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass$1Local.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass$1Local.class new file mode 100644 index 000000000000..7b5cd401171a Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass$1Local.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass.class new file mode 100644 index 000000000000..fc9073b3b1d1 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestLocalClass.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException$1.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException$1.class new file mode 100644 index 000000000000..e626366787d3 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException$1.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException.class new file mode 100644 index 000000000000..b6c514ab15de Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestThrowException.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class index 244dfad62aca..229e1b9d193e 100644 Binary files a/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class and b/plugins/java-decompiler/engine/testData/classes/pkg/TestTryCatchFinally.class differ diff --git a/plugins/java-decompiler/engine/testData/results/InvalidMethodSignature.dec b/plugins/java-decompiler/engine/testData/results/InvalidMethodSignature.dec index 3b1bee4d20a9..24b7c852219b 100644 --- a/plugins/java-decompiler/engine/testData/results/InvalidMethodSignature.dec +++ b/plugins/java-decompiler/engine/testData/results/InvalidMethodSignature.dec @@ -13,14 +13,36 @@ class i implements bg { i(b var1, j var2) { this.b = var1; - this.a = var2; + this.a = var2;// 1 } public void a(c var1, k var2, boolean var3) { - File var4 = this.a.b().a(var1); - b.a(this.b).add(var4); + File var4 = this.a.b().a(var1);// 2 + b.a(this.b).add(var4);// 3 } public void a(a.a.a.a.c.b var1) { } } + +class 'a/a/a/a/e/f/i' { + method ' (La/a/a/a/e/f/b;La/a/a/a/c/j;)V' { + 2 14 + 7 15 + } + + method 'a (La/a/a/a/c/c;La/a/a/a/a/k;Z)V' { + 1 19 + 4 19 + a 19 + f 19 + 12 20 + 15 20 + 1a 20 + } +} + +Lines mapping: +1 <-> 16 +2 <-> 20 +3 <-> 21 diff --git a/plugins/java-decompiler/engine/testData/results/TestAmbiguousCall.dec b/plugins/java-decompiler/engine/testData/results/TestAmbiguousCall.dec index b335867ca75f..caeb41d8ed38 100644 --- a/plugins/java-decompiler/engine/testData/results/TestAmbiguousCall.dec +++ b/plugins/java-decompiler/engine/testData/results/TestAmbiguousCall.dec @@ -8,11 +8,35 @@ class TestAmbiguousCall { } void test() { - IllegalArgumentException var1 = new IllegalArgumentException(); - this.m1((RuntimeException)var1, "RE"); - this.m1(var1, "IAE"); - IllegalArgumentException var2 = new IllegalArgumentException(); - this.m1((RuntimeException)var2, "RE"); - this.m1((IllegalArgumentException)var2, "IAE"); + IllegalArgumentException var1 = new IllegalArgumentException();// 8 + this.m1((RuntimeException)var1, "RE");// 9 + this.m1(var1, "IAE");// 10 + IllegalArgumentException var2 = new IllegalArgumentException();// 12 + this.m1((RuntimeException)var2, "RE");// 13 + this.m1((IllegalArgumentException)var2, "IAE");// 14 } } + +class 'pkg/TestAmbiguousCall' { + method 'test ()V' { + 7 10 + a 11 + c 11 + 11 12 + 13 12 + 1d 13 + 20 14 + 22 14 + 27 15 + 2a 15 + 2c 15 + } +} + +Lines mapping: +8 <-> 11 +9 <-> 12 +10 <-> 13 +12 <-> 14 +13 <-> 15 +14 <-> 16 diff --git a/plugins/java-decompiler/engine/testData/results/TestAmbiguousCallWithDebugInfo.dec b/plugins/java-decompiler/engine/testData/results/TestAmbiguousCallWithDebugInfo.dec index da3baa9663ad..6380d6db06a3 100644 --- a/plugins/java-decompiler/engine/testData/results/TestAmbiguousCallWithDebugInfo.dec +++ b/plugins/java-decompiler/engine/testData/results/TestAmbiguousCallWithDebugInfo.dec @@ -8,11 +8,35 @@ class TestAmbiguousCall { } void test() { - IllegalArgumentException iae = new IllegalArgumentException(); - this.m1((RuntimeException)iae, "RE"); - this.m1(iae, "IAE"); - IllegalArgumentException re = new IllegalArgumentException(); - this.m1((RuntimeException)re, "RE"); - this.m1((IllegalArgumentException)re, "IAE"); + IllegalArgumentException iae = new IllegalArgumentException();// 8 + this.m1((RuntimeException)iae, "RE");// 9 + this.m1(iae, "IAE");// 10 + IllegalArgumentException re = new IllegalArgumentException();// 12 + this.m1((RuntimeException)re, "RE");// 13 + this.m1((IllegalArgumentException)re, "IAE");// 14 } } + +class 'pkg/TestAmbiguousCall' { + method 'test ()V' { + 7 10 + a 11 + c 11 + 11 12 + 13 12 + 1d 13 + 20 14 + 22 14 + 27 15 + 2a 15 + 2c 15 + } +} + +Lines mapping: +8 <-> 11 +9 <-> 12 +10 <-> 13 +12 <-> 14 +13 <-> 15 +14 <-> 16 diff --git a/plugins/java-decompiler/engine/testData/results/TestAnonymousClass.dec b/plugins/java-decompiler/engine/testData/results/TestAnonymousClass.dec new file mode 100644 index 000000000000..18cfaefd1b39 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestAnonymousClass.dec @@ -0,0 +1,142 @@ +package pkg; + +public abstract class TestAnonymousClass { + public static final Runnable R3 = new Runnable() { + public void run() { + boolean var1 = true;// 28 + boolean var2 = true;// 29 + } + }; + public static final Runnable R = new Runnable() { + public void run() { + boolean var1 = true;// 45 + boolean var2 = true;// 46 + } + }; + public static final Runnable R1 = new Runnable() { + public void run() { + boolean var1 = true;// 53 + boolean var2 = true;// 54 + } + }; + + void foo(int var1) throws Exception { + if(var1 > 0) {// 10 + TestAnonymousClass.I var2 = new TestAnonymousClass.I() { + public void foo() throws Exception { + boolean var1 = true;// 13 + boolean var2 = true;// 14 + } + };// 11 + var2.foo();// 17 + } else { + System.out.println(5);// 21 + } + + } + + void boo() { + boolean var1 = true;// 35 + } + + void zoo() { + boolean var1 = true;// 39 + } + + private static class Inner { + private static final Runnable R_I = new Runnable() { + public void run() { + boolean var1 = true;// 66 + boolean var2 = true;// 67 + } + }; + } + + interface I { + void foo() throws Exception; + } +} + +class 'pkg/TestAnonymousClass$2' { + method 'run ()V' { + 0 5 + 1 5 + 2 6 + 3 6 + } +} + +class 'pkg/TestAnonymousClass$3' { + method 'run ()V' { + 0 11 + 1 11 + 2 12 + 3 12 + } +} + +class 'pkg/TestAnonymousClass$4' { + method 'run ()V' { + 0 17 + 1 17 + 2 18 + 3 18 + } +} + +class 'pkg/TestAnonymousClass$1' { + method 'foo ()V' { + 0 26 + 1 26 + 2 27 + 3 27 + } +} + +class 'pkg/TestAnonymousClass' { + method 'foo (I)V' { + 1 23 + c 29 + e 30 + 16 32 + 19 32 + 1a 32 + } + + method 'boo ()V' { + 0 38 + 1 38 + } + + method 'zoo ()V' { + 0 42 + 1 42 + } +} + +class 'pkg/TestAnonymousClass$Inner$1' { + method 'run ()V' { + 0 48 + 1 48 + 2 49 + 3 49 + } +} + +Lines mapping: +10 <-> 24 +11 <-> 30 +13 <-> 27 +14 <-> 28 +17 <-> 31 +21 <-> 33 +28 <-> 6 +29 <-> 7 +35 <-> 39 +39 <-> 43 +45 <-> 12 +46 <-> 13 +53 <-> 18 +54 <-> 19 +66 <-> 49 +67 <-> 50 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassCast.dec b/plugins/java-decompiler/engine/testData/results/TestClassCast.dec index e09162ca0f5f..7593d6d01a57 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassCast.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassCast.dec @@ -5,11 +5,30 @@ import java.util.List; public class TestClassCast { public void test(List var1) { - Object var2 = var1; - if(var1 != null) { - ((List)(var2 = new ArrayList(var1))).add("23"); + Object var2 = var1;// 22 + if(var1 != null) {// 23 + ((List)(var2 = new ArrayList(var1))).add("23");// 24 } - System.out.println(((List)var2).size()); + System.out.println(((List)var2).size());// 26 } } + +class 'pkg/TestClassCast' { + method 'test (Ljava/util/List;)V' { + 1 7 + 3 8 + f 9 + 10 9 + 12 9 + 18 12 + 1c 12 + 21 12 + } +} + +Lines mapping: +22 <-> 8 +23 <-> 9 +24 <-> 10 +26 <-> 13 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassFields.dec b/plugins/java-decompiler/engine/testData/results/TestClassFields.dec index 749d828c2a71..1415306b340d 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassFields.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassFields.dec @@ -5,6 +5,17 @@ public class TestClassFields { private static String[] names = new String[]{"name1", "name2"}; static { - sizes = new int[names.length]; + sizes = new int[names.length];// 26 } } + +class 'pkg/TestClassFields' { + method ' ()V' { + 11 7 + 14 7 + 17 7 + } +} + +Lines mapping: +26 <-> 8 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassLambda.dec b/plugins/java-decompiler/engine/testData/results/TestClassLambda.dec index d0485d352461..5dadaf7581f8 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassLambda.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassLambda.dec @@ -13,61 +13,161 @@ public class TestClassLambda { public int field = 0; public void testLambda() { - List var1 = Arrays.asList(new Integer[]{Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7)}); - int var2 = (int)Math.random(); - var1.forEach((var2x) -> { + List var1 = Arrays.asList(new Integer[]{Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7)});// 27 + int var2 = (int)Math.random();// 28 + var1.forEach((var2x) -> {// 30 int var3 = 2 * var2x.intValue(); System.out.println(var3 + var2 + this.field); }); } public void testLambda1() { - int var1 = (int)Math.random(); + int var1 = (int)Math.random();// 37 Runnable var2 = () -> { System.out.println("hello1" + var1); - }; + };// 38 Runnable var3 = () -> { System.out.println("hello2" + var1); - }; + };// 39 } public void testLambda2() { - reduce((var0, var1) -> { + reduce((var0, var1) -> {// 43 return Math.max(var0, var1); }); } public void testLambda3() { - reduce(Math::max); + reduce(Math::max);// 47 } public void testLambda4() { - reduce(TestClassLambda::localMax); + reduce(TestClassLambda::localMax);// 51 } public void testLambda5() { - String var1 = "abcd"; - function(var1::toString); + String var1 = "abcd";// 55 + function(var1::toString);// 56 } public void testLambda6() { - ArrayList var1 = new ArrayList(); - int var2 = var1.size() * 2; - int var3 = var1.size() * 5; - var1.removeIf((var2x) -> { + ArrayList var1 = new ArrayList();// 60 + int var2 = var1.size() * 2;// 61 + int var3 = var1.size() * 5;// 62 + var1.removeIf((var2x) -> {// 63 return var2 >= var2x.length() && var2x.length() <= var3; }); } public static OptionalInt reduce(IntBinaryOperator var0) { - return null; + return null;// 67 } public static String function(Supplier var0) { - return (String)var0.get(); + return (String)var0.get();// 71 } public static int localMax(int var0, int var1) { - return 0; + return 0;// 75 } } + +class 'pkg/TestClassLambda' { + method 'testLambda ()V' { + 7 15 + 8 15 + e 15 + f 15 + 15 15 + 16 15 + 1c 15 + 1d 15 + 23 15 + 24 15 + 2a 15 + 2c 15 + 33 15 + 35 15 + 39 15 + 3c 15 + 3d 16 + 40 16 + 41 16 + 4a 17 + } + + method 'testLambda1 ()V' { + 0 24 + 3 24 + 4 24 + b 27 + 12 30 + } + + method 'testLambda2 ()V' { + 5 34 + } + + method 'testLambda3 ()V' { + 5 40 + } + + method 'testLambda4 ()V' { + 5 44 + } + + method 'testLambda5 ()V' { + 0 48 + 2 48 + e 49 + } + + method 'testLambda6 ()V' { + 7 53 + 9 54 + e 54 + f 54 + 10 54 + 12 55 + 17 55 + 18 55 + 19 55 + 22 56 + } + + method 'reduce (Ljava/util/function/IntBinaryOperator;)Ljava/util/OptionalInt;' { + 0 62 + 1 62 + } + + method 'function (Ljava/util/function/Supplier;)Ljava/lang/String;' { + 1 66 + 6 66 + 9 66 + } + + method 'localMax (II)I' { + 0 70 + 1 70 + } +} + +Lines mapping: +27 <-> 16 +28 <-> 17 +30 <-> 18 +37 <-> 25 +38 <-> 28 +39 <-> 31 +43 <-> 35 +47 <-> 41 +51 <-> 45 +55 <-> 49 +56 <-> 50 +60 <-> 54 +61 <-> 55 +62 <-> 56 +63 <-> 57 +67 <-> 63 +71 <-> 67 +75 <-> 71 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassLoop.dec b/plugins/java-decompiler/engine/testData/results/TestClassLoop.dec index 74b8bac5d5e7..5384a981e0f3 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassLoop.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassLoop.dec @@ -3,16 +3,16 @@ package pkg; public class TestClassLoop { public static void testSimpleInfinite() { while(true) { - System.out.println(); + System.out.println();// 23 } } public static void testFinally() { - boolean var0 = Math.random() > 0.0D; + boolean var0 = Math.random() > 0.0D;// 29 while(true) { try { - if(!var0) { + if(!var0) {// 33 return; } } finally { @@ -22,16 +22,16 @@ public class TestClassLoop { } public static void testFinallyContinue() { - boolean var0 = Math.random() > 0.0D; + boolean var0 = Math.random() > 0.0D;// 45 while(true) { while(true) { try { - System.out.println("1"); + System.out.println("1");// 49 break; } finally { if(var0) { - System.out.println("3"); + System.out.println("3");// 53 continue; } } @@ -41,3 +41,39 @@ public class TestClassLoop { } } } + +class 'pkg/TestClassLoop' { + method 'testSimpleInfinite ()V' { + 0 5 + 3 5 + } + + method 'testFinally ()V' { + 0 10 + 3 10 + 4 10 + d 10 + f 14 + } + + method 'testFinallyContinue ()V' { + 0 24 + 3 24 + 4 24 + d 24 + e 29 + 11 29 + 13 29 + 2a 33 + 2d 33 + 2f 33 + } +} + +Lines mapping: +23 <-> 6 +29 <-> 11 +33 <-> 15 +45 <-> 25 +49 <-> 30 +53 <-> 34 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassNestedInitializer.dec b/plugins/java-decompiler/engine/testData/results/TestClassNestedInitializer.dec index 585b01a0261c..b9fa69cdb22e 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassNestedInitializer.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassNestedInitializer.dec @@ -8,7 +8,27 @@ public class TestClassNestedInitializer { { this.secret = "one"; } - }; - System.out.println(var1.secret); + };// 22 + System.out.println(var1.secret);// 23 } } + +class 'pkg/TestClassNestedInitializer$1' { + method ' (Lpkg/TestClassNestedInitializer;)V' { + a 8 + c 8 + } +} + +class 'pkg/TestClassNestedInitializer' { + method 'test ()V' { + 8 10 + 9 11 + d 11 + 10 11 + } +} + +Lines mapping: +22 <-> 11 +23 <-> 12 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassSwitch.dec b/plugins/java-decompiler/engine/testData/results/TestClassSwitch.dec index 50efbe9b16f9..695350fad6b6 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassSwitch.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassSwitch.dec @@ -2,13 +2,32 @@ package pkg; public class TestClassSwitch { public void testCaseOrder(int var1) { - switch(var1) { + switch(var1) {// 22 case 5: - System.out.println(5); + System.out.println(5);// 27 default: - return; + return;// 29 case 13: - System.out.println(13); + System.out.println(13);// 24 } } } + +class 'pkg/TestClassSwitch' { + method 'testCaseOrder (I)V' { + 1 4 + 1c 10 + 1f 10 + 21 10 + 25 6 + 28 6 + 29 6 + 2c 8 + } +} + +Lines mapping: +22 <-> 5 +24 <-> 11 +27 <-> 7 +29 <-> 9 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassTypes.dec b/plugins/java-decompiler/engine/testData/results/TestClassTypes.dec index 7a50473fc3e7..f2a3fdbbfbea 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassTypes.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassTypes.dec @@ -5,45 +5,122 @@ import java.util.List; public class TestClassTypes { public void testBoolean() { - byte var1 = 0; - long var2 = System.currentTimeMillis(); - if(var2 % 2L > 0L) { - var1 = 1; - } else if(var2 % 3L > 0L) { - var1 = 2; + byte var1 = 0;// 25 + long var2 = System.currentTimeMillis();// 26 + if(var2 % 2L > 0L) {// 28 + var1 = 1;// 29 + } else if(var2 % 3L > 0L) {// 31 + var1 = 2;// 32 } - if(var1 == 1) { - System.out.println(); + if(var1 == 1) {// 35 + System.out.println();// 36 } } public boolean testBit(int var1) { - return (var1 & 1) == 1; + return (var1 & 1) == 1;// 41 } public void testSwitchConsts(int var1) { - switch(var1) { + switch(var1) {// 46 case 88: - System.out.println("1"); + System.out.println("1");// 48 break; case 656: - System.out.println("2"); + System.out.println("2");// 51 break; case 65201: case 65489: - System.out.println("3"); + System.out.println("3");// 55 } } public void testAssignmentType(List var1) { - Object var2 = var1; - if(var1 != null) { - ((List)(var2 = new ArrayList(var1))).add("23"); + Object var2 = var1;// 61 + if(var1 != null) {// 63 + ((List)(var2 = new ArrayList(var1))).add("23");// 64 } - System.out.println(((List)var2).size()); + System.out.println(((List)var2).size());// 67 } } + +class 'pkg/TestClassTypes' { + method 'testBoolean ()V' { + 0 7 + 1 7 + 2 8 + 5 8 + 7 9 + a 9 + b 9 + c 9 + d 9 + 10 10 + 11 10 + 16 11 + 19 11 + 1a 11 + 1b 11 + 1c 11 + 1f 12 + 20 12 + 22 15 + 23 15 + 26 16 + 29 16 + } + + method 'testBit (I)Z' { + 1 22 + 2 22 + 3 22 + c 22 + } + + method 'testSwitchConsts (I)V' { + 1 26 + 2c 28 + 2f 28 + 31 28 + 37 31 + 3a 31 + 3c 31 + 42 35 + 45 35 + 47 35 + } + + method 'testAssignmentType (Ljava/util/List;)V' { + 1 41 + 3 42 + f 43 + 10 43 + 12 43 + 18 46 + 1c 46 + 21 46 + } +} + +Lines mapping: +25 <-> 8 +26 <-> 9 +28 <-> 10 +29 <-> 11 +31 <-> 12 +32 <-> 13 +35 <-> 16 +36 <-> 17 +41 <-> 23 +46 <-> 27 +48 <-> 29 +51 <-> 32 +55 <-> 36 +61 <-> 42 +63 <-> 43 +64 <-> 44 +67 <-> 47 diff --git a/plugins/java-decompiler/engine/testData/results/TestClassVar.dec b/plugins/java-decompiler/engine/testData/results/TestClassVar.dec index 4cfd27f7854d..14d2e070393d 100644 --- a/plugins/java-decompiler/engine/testData/results/TestClassVar.dec +++ b/plugins/java-decompiler/engine/testData/results/TestClassVar.dec @@ -5,12 +5,12 @@ public class TestClassVar { public int field_int = 0; public void testFieldSSAU() { - for(int var1 = 0; var1 < 10; ++var1) { + for(int var1 = 0; var1 < 10; ++var1) {// 26 try { - System.out.println(); + System.out.println();// 29 } finally { if(this.field_boolean) { - System.out.println(); + System.out.println();// 33 } } @@ -19,22 +19,65 @@ public class TestClassVar { } public Long testFieldSSAU1() { - return new Long((long)(this.field_int++)); + return new Long((long)(this.field_int++));// 40 } public void testComplexPropagation() { - int var1 = 0; + int var1 = 0;// 45 - while(var1 < 10) { + while(var1 < 10) {// 47 int var2; - for(var2 = var1; var1 < 10 && var1 == 0; ++var1) { + for(var2 = var1; var1 < 10 && var1 == 0; ++var1) {// 49 ; } - if(var2 != var1) { - System.out.println(); + if(var2 != var1) {// 54 + System.out.println();// 55 } } } } + +class 'pkg/TestClassVar' { + method 'testFieldSSAU ()V' { + 0 7 + 1 7 + 3 7 + 8 9 + b 9 + 26 12 + 29 12 + } + + method 'testFieldSSAU1 ()Ljava/lang/Long;' { + 6 21 + b 21 + f 21 + 13 21 + } + + method 'testComplexPropagation ()V' { + 0 25 + 1 25 + 3 27 + 9 29 + b 29 + 14 29 + 1c 33 + 1f 34 + 22 34 + } +} + +Lines mapping: +26 <-> 8 +29 <-> 10 +33 <-> 13 +40 <-> 22 +45 <-> 26 +47 <-> 28 +49 <-> 30 +51 <-> 30 +54 <-> 34 +55 <-> 35 diff --git a/plugins/java-decompiler/engine/testData/results/TestCodeConstructs.dec b/plugins/java-decompiler/engine/testData/results/TestCodeConstructs.dec index eb9de8daa07a..eeb9c19a91e2 100644 --- a/plugins/java-decompiler/engine/testData/results/TestCodeConstructs.dec +++ b/plugins/java-decompiler/engine/testData/results/TestCodeConstructs.dec @@ -4,10 +4,26 @@ class TestCodeConstructs { private int count = 0; void expressions() { - (new String()).hashCode(); + (new String()).hashCode();// 20 } Integer fieldIncrement() { - return new Integer(this.count++); + return new Integer(this.count++);// 25 } } + +class 'pkg/TestCodeConstructs' { + method 'expressions ()V' { + 7 6 + } + + method 'fieldIncrement ()Ljava/lang/Integer;' { + 6 10 + b 10 + 12 10 + } +} + +Lines mapping: +20 <-> 7 +25 <-> 11 diff --git a/plugins/java-decompiler/engine/testData/results/TestConstants.dec b/plugins/java-decompiler/engine/testData/results/TestConstants.dec index 216da8e98468..47f4c1d3a72b 100644 --- a/plugins/java-decompiler/engine/testData/results/TestConstants.dec +++ b/plugins/java-decompiler/engine/testData/results/TestConstants.dec @@ -71,3 +71,4 @@ public class TestConstants { Class value(); } } + diff --git a/plugins/java-decompiler/engine/testData/results/TestDebugSymbols.dec b/plugins/java-decompiler/engine/testData/results/TestDebugSymbols.dec index 42ae7a8c5513..e96eb3328706 100644 --- a/plugins/java-decompiler/engine/testData/results/TestDebugSymbols.dec +++ b/plugins/java-decompiler/engine/testData/results/TestDebugSymbols.dec @@ -2,10 +2,40 @@ package pkg; class TestDebugSymbols { private int m() { - String text = "text"; - long prolonged = 42L; - float decimated = (float)prolonged / 10.0F; - double doubled = (double)(2.0F * decimated); - return (text + ":" + prolonged + ":" + decimated + ":" + doubled).length(); + String text = "text";// 21 + long prolonged = 42L;// 22 + float decimated = (float)prolonged / 10.0F;// 23 + double doubled = (double)(2.0F * decimated);// 24 + return (text + ":" + prolonged + ":" + decimated + ":" + doubled).length();// 25 } } + +class 'pkg/TestDebugSymbols' { + method 'm ()I' { + 0 4 + 2 4 + 3 5 + 6 5 + 8 6 + 9 6 + b 6 + c 6 + e 7 + 11 7 + 12 7 + 13 7 + 20 8 + 29 8 + 33 8 + 3d 8 + 40 8 + 43 8 + } +} + +Lines mapping: +21 <-> 5 +22 <-> 6 +23 <-> 7 +24 <-> 8 +25 <-> 9 diff --git a/plugins/java-decompiler/engine/testData/results/TestDeprecations.dec b/plugins/java-decompiler/engine/testData/results/TestDeprecations.dec index 237ac9c72348..e423854d729a 100644 --- a/plugins/java-decompiler/engine/testData/results/TestDeprecations.dec +++ b/plugins/java-decompiler/engine/testData/results/TestDeprecations.dec @@ -1,6 +1,6 @@ package pkg; -public class TestDeprecations { +public abstract class TestDeprecations { /** @deprecated */ public int byComment; /** @deprecated */ @@ -9,19 +9,70 @@ public class TestDeprecations { /** @deprecated */ public void byComment() { + boolean var1 = true;// 27 } + /** @deprecated */ + public abstract void byCommentAbstract(); + /** @deprecated */ @Deprecated public void byAnno() { + boolean var1 = true;// 35 } + /** @deprecated */ + @Deprecated + public abstract void byAnnoAbstract(); + /** @deprecated */ @Deprecated public static class ByAnno { + int a = 5; + + void foo() { + boolean var1 = true;// 55 + } } /** @deprecated */ public static class ByComment { + int a = 5; + + void foo() { + boolean var1 = true;// 46 + } } } + +class 'pkg/TestDeprecations' { + method 'byComment ()V' { + 0 11 + 1 11 + } + + method 'byAnno ()V' { + 0 20 + 1 20 + } +} + +class 'pkg/TestDeprecations$ByAnno' { + method 'foo ()V' { + 0 33 + 1 33 + } +} + +class 'pkg/TestDeprecations$ByComment' { + method 'foo ()V' { + 0 42 + 1 42 + } +} + +Lines mapping: +27 <-> 12 +35 <-> 21 +46 <-> 43 +55 <-> 34 diff --git a/plugins/java-decompiler/engine/testData/results/TestEnum.dec b/plugins/java-decompiler/engine/testData/results/TestEnum.dec index 3184741d4043..e08f341a6065 100644 --- a/plugins/java-decompiler/engine/testData/results/TestEnum.dec +++ b/plugins/java-decompiler/engine/testData/results/TestEnum.dec @@ -18,10 +18,25 @@ public enum TestEnum { } private TestEnum() { - this("?"); + this("?");// 34 } private TestEnum(@Deprecated String var3) { - this.s = var3; + this.s = var3;// 35 } } + +class 'pkg/TestEnum' { + method ' (Ljava/lang/String;I)V' { + 3 20 + 5 20 + } + + method ' (Ljava/lang/String;ILjava/lang/String;)V' { + 8 24 + } +} + +Lines mapping: +34 <-> 21 +35 <-> 25 diff --git a/plugins/java-decompiler/engine/testData/results/TestExtendsList.dec b/plugins/java-decompiler/engine/testData/results/TestExtendsList.dec index b4aacf6e126a..6f116dbad41c 100644 --- a/plugins/java-decompiler/engine/testData/results/TestExtendsList.dec +++ b/plugins/java-decompiler/engine/testData/results/TestExtendsList.dec @@ -2,10 +2,26 @@ package pkg; public class TestExtendsList { static > T m1(T var0) { - return null; + return null;// 20 } static > T m2(T var0) { - return null; + return null;// 24 } } + +class 'pkg/TestExtendsList' { + method 'm1 (Ljava/lang/Comparable;)Ljava/lang/Comparable;' { + 0 4 + 1 4 + } + + method 'm2 (Ljava/lang/Object;)Ljava/lang/Object;' { + 0 8 + 1 8 + } +} + +Lines mapping: +20 <-> 5 +24 <-> 9 diff --git a/plugins/java-decompiler/engine/testData/results/TestInnerClassConstructor.dec b/plugins/java-decompiler/engine/testData/results/TestInnerClassConstructor.dec index 9b63154af169..3db62038d2f6 100644 --- a/plugins/java-decompiler/engine/testData/results/TestInnerClassConstructor.dec +++ b/plugins/java-decompiler/engine/testData/results/TestInnerClassConstructor.dec @@ -2,16 +2,40 @@ package pkg; class TestInnerClassConstructor { void m() { - new TestInnerClassConstructor.Inner("text"); + new TestInnerClassConstructor.Inner("text");// 5 } void n(String var1) { - System.out.println("n(): " + var1); + System.out.println("n(): " + var1);// 9 } final class Inner { private Inner(String var2) { - TestInnerClassConstructor.this.n(var2); + TestInnerClassConstructor.this.n(var2);// 14 } } } + +class 'pkg/TestInnerClassConstructor' { + method 'm ()V' { + 5 4 + } + + method 'n (Ljava/lang/String;)V' { + 0 8 + a 8 + 13 8 + 16 8 + } +} + +class 'pkg/TestInnerClassConstructor$Inner' { + method ' (Lpkg/TestInnerClassConstructor;Ljava/lang/String;)V' { + b 13 + } +} + +Lines mapping: +5 <-> 5 +9 <-> 9 +14 <-> 14 diff --git a/plugins/java-decompiler/engine/testData/results/TestLocalClass.dec b/plugins/java-decompiler/engine/testData/results/TestLocalClass.dec new file mode 100644 index 000000000000..8e511673bb18 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestLocalClass.dec @@ -0,0 +1,61 @@ +package pkg; + +public abstract class TestLocalClass { + void foo() { + boolean var1 = true;// 8 + class Local { + void foo() { + boolean var1 = true;// 11 + boolean var2 = true;// 12 + } + } + + Local var2 = new Local();// 15 + var2.foo();// 16 + } + + void boo() { + boolean var1 = true;// 20 + } + + void zoo() { + boolean var1 = true;// 24 + } +} + +class 'pkg/TestLocalClass$1Local' { + method 'foo ()V' { + 0 7 + 1 7 + 2 8 + 3 8 + } +} + +class 'pkg/TestLocalClass' { + method 'foo ()V' { + 0 4 + 1 4 + a 12 + c 13 + } + + method 'boo ()V' { + 0 17 + 1 17 + } + + method 'zoo ()V' { + 0 21 + 1 21 + } +} + +Lines mapping: +8 <-> 5 +11 <-> 8 +12 <-> 9 +15 <-> 13 +16 <-> 14 +20 <-> 18 +24 <-> 22 diff --git a/plugins/java-decompiler/engine/testData/results/TestMethodParameters.dec b/plugins/java-decompiler/engine/testData/results/TestMethodParameters.dec index e4c4724d7a7c..a45819211428 100644 --- a/plugins/java-decompiler/engine/testData/results/TestMethodParameters.dec +++ b/plugins/java-decompiler/engine/testData/results/TestMethodParameters.dec @@ -40,3 +40,4 @@ public class TestMethodParameters { } } } + diff --git a/plugins/java-decompiler/engine/testData/results/TestThrowException.dec b/plugins/java-decompiler/engine/testData/results/TestThrowException.dec new file mode 100644 index 000000000000..7bc460e5f519 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestThrowException.dec @@ -0,0 +1,39 @@ +package pkg; + +public class TestThrowException { + Runnable r; + + public TestThrowException(int var1) { + if(var1 > 0) {// 9 + throw new IllegalArgumentException("xxx");// 10 + } else { + this.r = new Runnable() {// 12 + public void run() { + boolean var1 = true;// 15 + } + }; + } + } +} + +class 'pkg/TestThrowException$1' { + method 'run ()V' { + 0 11 + 1 11 + } +} + +class 'pkg/TestThrowException' { + method ' (I)V' { + 5 6 + c 7 + 11 7 + 1b 9 + } +} + +Lines mapping: +9 <-> 7 +10 <-> 8 +12 <-> 10 +15 <-> 12 diff --git a/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec b/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec index 9840bfccb285..673238ec14fb 100644 --- a/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec +++ b/plugins/java-decompiler/engine/testData/results/TestTryCatchFinally.dec @@ -3,10 +3,10 @@ package pkg; public class TestTryCatchFinally { public void test1(String var1) { try { - System.out.println("sout1"); + System.out.println("sout1");// 24 } catch (Exception var9) { try { - System.out.println("sout2"); + System.out.println("sout2");// 27 } catch (Exception var8) { ; } @@ -16,9 +16,19 @@ public class TestTryCatchFinally { } + int foo(int var1) throws Exception { + if(var1 < 1) {// 39 + throw new RuntimeException();// 40 + } else if(var1 < 5) {// 41 + return var1;// 42 + } else { + throw new Exception();// 45 + } + } + public int test(String var1) { try { - int var2 = Integer.parseInt(var1); + int var2 = Integer.parseInt(var1);// 51 return var2; } catch (Exception var6) { System.out.println("Error" + var6); @@ -29,3 +39,39 @@ public class TestTryCatchFinally { return -1; } } + +class 'pkg/TestTryCatchFinally' { + method 'test1 (Ljava/lang/String;)V' { + 0 5 + 3 5 + 5 5 + 14 8 + 17 8 + 19 8 + } + + method 'foo (I)I' { + 1 19 + 2 19 + c 20 + e 21 + f 21 + 13 22 + 1b 24 + } + + method 'test (Ljava/lang/String;)I' { + 1 30 + 4 30 + } +} + +Lines mapping: +24 <-> 6 +27 <-> 9 +39 <-> 20 +40 <-> 21 +41 <-> 22 +42 <-> 23 +45 <-> 25 +51 <-> 31 diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestAnonymousClass.java b/plugins/java-decompiler/engine/testData/src/pkg/TestAnonymousClass.java new file mode 100644 index 000000000000..3c2e3b006266 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestAnonymousClass.java @@ -0,0 +1,71 @@ +package pkg; + +import java.lang.Exception; +import java.lang.Override; +import java.lang.Runnable; + +public abstract class TestAnonymousClass { + void foo(int i) + throws Exception { + if (i > 0) { + I r = new I() { + public void foo() throws Exception { + int a = 5; + int b = 5; + } + }; + r.foo(); + } + else { + final int x =5; + System.out.println(x); + } + } + + public static final Runnable R3 = new Runnable() { + @Override + public void run() { + int a =5; + int b =5; + } + }; + + + void boo() { + int a =5; + } + + void zoo() { + int a =5; + } + + public static final Runnable R = new Runnable() { + @Override + public void run() { + int a =5; + int b =5; + } + }; + + public static final Runnable R1 = new Runnable() { + @Override + public void run() { + int a =5; + int b =5; + } + }; + + interface I { + void foo() throws Exception; + } + + private static class Inner { + private static Runnable R_I = new Runnable() { + @Override + public void run() { + int a =5; + int b =5; + } + }; + } +} diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestDeprecations.java b/plugins/java-decompiler/engine/testData/src/pkg/TestDeprecations.java index 18ba0b5f10a6..0f6baad7d9fd 100644 --- a/plugins/java-decompiler/engine/testData/src/pkg/TestDeprecations.java +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestDeprecations.java @@ -15,7 +15,7 @@ */ package pkg; -public class TestDeprecations { +public abstract class TestDeprecations { /** @deprecated */ public int byComment; @@ -23,14 +23,36 @@ public class TestDeprecations { public int byAnno; /** @deprecated */ - public void byComment() { } - - @Deprecated - public void byAnno() { } + public void byComment() { + int a =5; + } /** @deprecated */ - public static class ByComment { } + public abstract void byCommentAbstract(); @Deprecated - public static class ByAnno { } + public void byAnno() { + int a =5; + } + + @Deprecated + public abstract void byAnnoAbstract(); + + /** @deprecated */ + public static class ByComment { + int a =5; + + void foo() { + int x = 5; + } + } + + @Deprecated + public static class ByAnno { + int a =5; + + void foo() { + int x = 5; + } + } } \ No newline at end of file diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestLocalClass.java b/plugins/java-decompiler/engine/testData/src/pkg/TestLocalClass.java new file mode 100644 index 000000000000..3667a9408ca3 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestLocalClass.java @@ -0,0 +1,26 @@ +package pkg; + +import java.lang.Override; +import java.lang.Runnable; + +public abstract class TestLocalClass { + void foo() { + int a =5; + class Local{ + void foo() { + int b = 5; + int v = 5; + } + }; + Local l = new Local(); + l.foo(); + } + + void boo() { + int a =5; + } + + void zoo() { + int a =5; + } +} diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestThrowException.java b/plugins/java-decompiler/engine/testData/src/pkg/TestThrowException.java new file mode 100644 index 000000000000..76d571a2c78d --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestThrowException.java @@ -0,0 +1,19 @@ +package pkg; + +import java.lang.Override; +import java.lang.Runnable; + +public class TestThrowException { + Runnable r; + public TestThrowException(int a) { + if (a > 0) { + throw new IllegalArgumentException("xxx"); + } + r = new Runnable() { + @Override + public void run() { + int a = 5; + } + }; + } +} diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java b/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java index da3588a3eb50..2c4980000480 100644 --- a/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestTryCatchFinally.java @@ -15,6 +15,9 @@ */ package pkg; +import java.lang.Exception; +import java.lang.RuntimeException; + public class TestTryCatchFinally { public void test1(String x) { try { @@ -32,6 +35,17 @@ public class TestTryCatchFinally { } } + int foo(int a) throws Exception { + if (a < 1) { + throw new RuntimeException(); + } else if ( a <5) { + return a; + } + else { + throw new Exception(); + } + } + public int test(String a) { try { return Integer.parseInt(a); diff --git a/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java b/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java index b04e42f80640..f2ed7234414e 100644 --- a/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java +++ b/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java @@ -65,9 +65,11 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase { } public void testStubCompatibility() { + Registry.get("decompiler.dump.original.lines").setValue(true); String path = PlatformTestUtil.getRtJarPath() + "!/java"; VirtualFile dir = getTestFile(path); doTestStubCompatibility(dir); + Registry.get("decompiler.dump.original.lines").setValue(false); } private void doTestStubCompatibility(VirtualFile root) { @@ -83,6 +85,15 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase { PsiElement mirror = ((ClsFileImpl)clsFile).getMirror(); String decompiled = mirror.getText(); assertTrue(file.getPath(), decompiled.contains(file.getNameWithoutExtension())); + + // check that no mapped line number is on an empty line + String prefix = "// "; + for (String s : decompiled.split("\n")) { + int pos = s.indexOf(prefix); + if (pos == 0 && prefix.length() < s.length() && Character.isDigit(s.charAt(prefix.length()))) { + fail("Incorrect line mapping in file " + file.getPath() + " line: " + s); + } + } } return true; } diff --git a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java index b91a878024b2..85d9fd90c102 100644 --- a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java +++ b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java @@ -57,7 +57,6 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx_en.properties\n" + " xxx_ru_RU.properties\n" + " X.txt\n" + - myStructure.getProjectFileRepresentation() + " External Libraries\n"; PlatformTestUtil.assertTreeEqual(pane.getTree(), structure); } @@ -74,7 +73,6 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx2.properties\n" + " yyy.properties\n" + " X.txt\n" + - myStructure.getProjectFileRepresentation() + " External Libraries\n"; PlatformTestUtil.assertTreeEqual(pane.getTree(), structure); @@ -94,7 +92,6 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx.properties\n" + " xxx_en.properties\n" + " X.txt\n" + - myStructure.getProjectFileRepresentation() + " External Libraries\n"; PlatformTestUtil.assertTreeEqual(pane.getTree(), structure); @@ -111,7 +108,6 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx_en.properties\n" + " xxx2.properties\n" + " yyy.properties\n" + - myStructure.getProjectFileRepresentation() + " External Libraries\n"; PlatformTestUtil.assertTreeEqual(pane.getTree(), structure); diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalStarter.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalStarter.java index 505b31648664..f220b1b11ac0 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalStarter.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalStarter.java @@ -1,7 +1,6 @@ package org.jetbrains.plugins.terminal; import com.intellij.ide.GeneralSettings; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.jediterm.terminal.*; import com.jediterm.terminal.emulator.JediEmulator; @@ -34,17 +33,7 @@ public class JBTerminalStarter extends TerminalStarter { public static void refreshAfterExecution() { if (GeneralSettings.getInstance().isSyncOnFrameActivation()) { //we need to refresh local file system after a command has been executed in the terminal - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - LocalFileSystem.getInstance().refresh(false); - } - }); - } - }); + LocalFileSystem.getInstance().refresh(true); } } } diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml index 50c8714e5bc0..76a1d65d4779 100644 --- a/xml/impl/resources/liveTemplates/zen_html.xml +++ b/xml/impl/resources/liveTemplates/zen_html.xml @@ -517,6 +517,15 @@