mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.intellij.compiler.impl.javaCompiler;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,7 +27,7 @@ import java.io.IOException;
|
||||
* @author cdr
|
||||
*/
|
||||
public class FileObject {
|
||||
private static final byte[] NOT_LOADED = new byte[0];
|
||||
private static final byte[] NOT_LOADED = ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
|
||||
private final File myFile;
|
||||
private final byte[] myContent;
|
||||
|
||||
@@ -239,6 +239,15 @@ public class JUnitUtil {
|
||||
return testMethod;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod findSuiteMethod(PsiClass clazz) {
|
||||
final PsiMethod[] suiteMethods = clazz.findMethodsByName(SUITE_METHOD_NAME, false);
|
||||
for (PsiMethod method : suiteMethods) {
|
||||
if (isSuiteMethod(method)) return method;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class TestMethodFilter implements Condition<PsiMethod> {
|
||||
private final PsiClass myClass;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -24,6 +26,7 @@ import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.ZipUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -50,7 +53,8 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
stream = new ZipOutputStream(new FileOutputStream(file));
|
||||
VirtualFile dir = project.getBaseDir();
|
||||
|
||||
VirtualFile dir = getDirectoryToSave(project, dialog.getModuleToSave());
|
||||
String description = dialog.getDescription();
|
||||
if (descriptionFile == null) {
|
||||
stream.putNextEntry(new ZipEntry(dir.getName() + "/" + ArchivedProjectTemplate.DESCRIPTION_PATH));
|
||||
@@ -80,6 +84,19 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtualFile getDirectoryToSave(Project project, @Nullable String moduleName) {
|
||||
if (moduleName == null) {
|
||||
return project.getBaseDir();
|
||||
}
|
||||
else {
|
||||
Module module = ModuleManager.getInstance(project).findModuleByName(moduleName);
|
||||
assert module != null : "Can't find module " + moduleName;
|
||||
VirtualFile moduleFile = module.getModuleFile();
|
||||
assert moduleFile != null;
|
||||
return moduleFile.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = getEventProject(e);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.platform.templates.SaveProjectAsTemplateDialog">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="170"/>
|
||||
<xy x="20" y="20" width="370" height="170"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b149e" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="6b257"/>
|
||||
@@ -19,12 +19,12 @@
|
||||
</component>
|
||||
<vspacer id="bd33">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="6b257" class="javax.swing.JTextField" binding="myName">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -32,7 +32,7 @@
|
||||
</component>
|
||||
<component id="fbd8f" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Description:"/>
|
||||
@@ -40,12 +40,26 @@
|
||||
</component>
|
||||
<component id="94559" class="com.intellij.ui.EditorTextField" binding="myDescription">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="100" height="-1"/>
|
||||
<grid row="2" column="1" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="-1" height="60"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="61a42" class="javax.swing.JComboBox" binding="myModuleCombo">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="66b82" class="javax.swing.JLabel" binding="myModuleLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Save:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -17,19 +17,26 @@ package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -37,13 +44,32 @@ import java.io.IOException;
|
||||
*/
|
||||
public class SaveProjectAsTemplateDialog extends DialogWrapper {
|
||||
|
||||
private static final String WHOLE_PROJECT = "<whole project>";
|
||||
private JPanel myPanel;
|
||||
private JTextField myName;
|
||||
private EditorTextField myDescription;
|
||||
private JComboBox myModuleCombo;
|
||||
private JLabel myModuleLabel;
|
||||
|
||||
protected SaveProjectAsTemplateDialog(@NotNull Project project, @Nullable VirtualFile descriptionFile) {
|
||||
super(project);
|
||||
|
||||
setTitle("Save Project As Template");
|
||||
Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
if (modules.length < 2) {
|
||||
myModuleLabel.setVisible(false);
|
||||
myModuleCombo.setVisible(false);
|
||||
}
|
||||
else {
|
||||
List<String> items = new ArrayList<String>(ContainerUtil.map(modules, new Function<Module, String>() {
|
||||
@Override
|
||||
public String fun(Module module) {
|
||||
return module.getName();
|
||||
}
|
||||
}));
|
||||
items.add(WHOLE_PROJECT);
|
||||
myModuleCombo.setModel(new CollectionComboBoxModel(items, WHOLE_PROJECT));
|
||||
}
|
||||
myDescription.setFileType(FileTypeManager.getInstance().getFileTypeByExtension(".html"));
|
||||
if (descriptionFile != null) {
|
||||
try {
|
||||
@@ -95,5 +121,12 @@ public class SaveProjectAsTemplateDialog extends DialogWrapper {
|
||||
return myDescription.getText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getModuleToSave() {
|
||||
String item = (String)myModuleCombo.getSelectedItem();
|
||||
if (item == null || item.equals(WHOLE_PROJECT)) return null;
|
||||
return item;
|
||||
}
|
||||
|
||||
private final static Logger LOG = Logger.getInstance(SaveProjectAsTemplateDialog.class);
|
||||
}
|
||||
|
||||
@@ -792,7 +792,9 @@ public class JavaCompletionUtil {
|
||||
|
||||
boolean insertAdditionalSemicolon = true;
|
||||
final PsiReferenceExpression referenceExpression = PsiTreeUtil.getTopmostParentOfType(context.getFile().findElementAt(context.getStartOffset()), PsiReferenceExpression.class);
|
||||
if (referenceExpression != null) {
|
||||
if (referenceExpression instanceof PsiMethodReferenceExpression && LambdaUtil.insertSemicolon(referenceExpression.getParent())) {
|
||||
insertAdditionalSemicolon = false;
|
||||
} else if (referenceExpression != null) {
|
||||
PsiElement parent = referenceExpression.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
parent = parent.getParent();
|
||||
|
||||
+20
-14
@@ -199,6 +199,25 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiElement elementParent = myElement.getParent();
|
||||
if (!(elementParent instanceof PsiMethodReferenceExpression) && checkStaticFlag(element)) return true;
|
||||
|
||||
if (element instanceof PsiPackage && myScope instanceof PsiClass) {
|
||||
if (!(elementParent instanceof PsiQualifiedReference && ((PsiQualifiedReference)elementParent).getQualifier() != null)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (satisfies(element, state) && isAccessible(element)) {
|
||||
CompletionElement element1 = new CompletionElement((PsiNamedElement)element, state.get(PsiSubstitutor.KEY));
|
||||
if (myResultNames.add(element1.getUniqueId())) {
|
||||
myResults.add(element1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkStaticFlag(PsiElement element) {
|
||||
if (!(element instanceof PsiClass) && element instanceof PsiModifierListOwner) {
|
||||
PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)element;
|
||||
if (myStatic) {
|
||||
@@ -216,20 +235,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiElement elementParent = myElement.getParent();
|
||||
if (element instanceof PsiPackage && myScope instanceof PsiClass) {
|
||||
if (!(elementParent instanceof PsiQualifiedReference && ((PsiQualifiedReference)elementParent).getQualifier() != null)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (satisfies(element, state) && isAccessible(element)) {
|
||||
CompletionElement element1 = new CompletionElement((PsiNamedElement)element, state.get(PsiSubstitutor.KEY));
|
||||
if (myResultNames.add(element1.getUniqueId())) {
|
||||
myResults.add(element1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean satisfies(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
|
||||
+1
@@ -644,6 +644,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
|
||||
if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass();
|
||||
Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
|
||||
if (element == null) return;
|
||||
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
|
||||
|
||||
if (refEntity instanceof RefElement) {
|
||||
|
||||
@@ -52,7 +52,8 @@ public class ReferenceAdjuster {
|
||||
public TreeElement process(TreeElement element, boolean addImports, boolean uncompleteCode) {
|
||||
IElementType elementType = element.getElementType();
|
||||
if (elementType == JavaElementType.JAVA_CODE_REFERENCE || elementType == JavaElementType.REFERENCE_EXPRESSION) {
|
||||
if (elementType == JavaElementType.JAVA_CODE_REFERENCE || element.getTreeParent().getElementType() == JavaElementType.REFERENCE_EXPRESSION || uncompleteCode) {
|
||||
final IElementType parentElementType = element.getTreeParent().getElementType();
|
||||
if (elementType == JavaElementType.JAVA_CODE_REFERENCE || parentElementType == JavaElementType.REFERENCE_EXPRESSION || parentElementType == JavaElementType.METHOD_REF_EXPRESSION || uncompleteCode) {
|
||||
final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)SourceTreeToPsiMap.treeElementToPsi(element);
|
||||
final PsiReferenceParameterList parameterList = ref.getParameterList();
|
||||
if (parameterList != null) {
|
||||
|
||||
@@ -566,13 +566,16 @@ public class LambdaUtil {
|
||||
if (lambdaExpression.getBody() instanceof PsiCodeBlock) {
|
||||
return true;
|
||||
}
|
||||
final PsiElement parent = lambdaExpression.getParent();
|
||||
if (parent instanceof PsiExpressionList || parent instanceof PsiExpression) {
|
||||
if (insertSemicolon(lambdaExpression.getParent())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean insertSemicolon(PsiElement parent) {
|
||||
return parent instanceof PsiExpressionList || parent instanceof PsiExpression;
|
||||
}
|
||||
|
||||
public static boolean isValidQualifier(PsiMethodReferenceExpression expression) {
|
||||
final PsiElement referenceNameElement = expression.getReferenceNameElement();
|
||||
if (referenceNameElement instanceof PsiKeyword) {
|
||||
|
||||
@@ -248,11 +248,16 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
|
||||
final PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass == null) return classType;
|
||||
assert classType.isValid();
|
||||
assert aClass.isValid();
|
||||
if (aClass instanceof PsiTypeParameter) {
|
||||
final PsiTypeParameter typeParameter = (PsiTypeParameter)aClass;
|
||||
if (containsInMap(typeParameter)) {
|
||||
return substituteTypeParameter(typeParameter);
|
||||
PsiType result = substituteTypeParameter(typeParameter);
|
||||
if (result != null) {
|
||||
assert result.isValid();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return classType;
|
||||
@@ -262,8 +267,9 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
if (!processClass(aClass, resolveResult.getSubstitutor(), hashMap)) {
|
||||
return null;
|
||||
}
|
||||
return JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory()
|
||||
.createType(aClass, createSubstitutor(hashMap), classType.getLanguageLevel());
|
||||
PsiClassType result = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(aClass, createSubstitutor(hashMap), classType.getLanguageLevel());
|
||||
assert result.isValid();
|
||||
return result;
|
||||
}
|
||||
|
||||
private PsiType substituteTypeParameter(final PsiTypeParameter typeParameter) {
|
||||
|
||||
@@ -199,7 +199,7 @@ public class PsiScopesUtil {
|
||||
substitutor = substitutor.putAll((PsiClass)target, types);
|
||||
}
|
||||
}
|
||||
else if (target instanceof PsiClass && !(ref instanceof PsiMethodReferenceExpression)) {
|
||||
else if (target instanceof PsiClass) {
|
||||
processor.handleEvent(JavaScopeProcessorEvent.START_STATIC, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void aaa(Test p) { return 1; }
|
||||
void test() {
|
||||
c(Test::<caret>);
|
||||
}
|
||||
void c(Comparator<Test> c){}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void aaa(Test p) { return 1; }
|
||||
void test() {
|
||||
c(Test::c);
|
||||
}
|
||||
void c(Comparator<Test> c){}
|
||||
}
|
||||
+1
-1
@@ -8,6 +8,6 @@ class NonStaticInner {
|
||||
Inner m(NonStaticInner rec);
|
||||
}
|
||||
static {
|
||||
I1 i1 = NonStaticInner.Inner::new;
|
||||
I1 i1 = Inner::new;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@ class StaticInner {
|
||||
|
||||
|
||||
static {
|
||||
I1 i1 = StaticInner.Inner::new;
|
||||
I1 i1 = Inner::new;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ class NonStaticInner3 {
|
||||
}
|
||||
|
||||
{
|
||||
I1<Foo> b1 = NonStaticInner3.Foo::new;
|
||||
I1<Foo> b1 = Foo::new;
|
||||
I2<Foo> b2 = () -> new Foo();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class NonStaticInner3 {
|
||||
|
||||
{
|
||||
I1<Foo> b1 = (i) -> new Foo(i);
|
||||
I2<Foo> b2 = NonStaticInner3.Foo::new;
|
||||
I2<Foo> b2 = Foo::new;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class NonStaticInner3 {
|
||||
}
|
||||
|
||||
{
|
||||
I3<Foo> b1 = NonStaticInner3.Foo::new;
|
||||
I3<Foo> b1 = Foo::new;
|
||||
I4<Foo> b2 = (rec) -> rec.new Foo();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,6 +28,6 @@ class NonStaticInner3 {
|
||||
|
||||
{
|
||||
I3<Foo> b1 = (rec, i) -> rec.new Foo(i);
|
||||
I4<Foo> b2 = NonStaticInner3.Foo::new;
|
||||
I4<Foo> b2 = Foo::new;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,6 +8,6 @@ class NonStaticInner3 {
|
||||
}
|
||||
|
||||
{
|
||||
I1<Foo> b2 = NonStaticInner3.Foo::new;
|
||||
I1<Foo> b2 = Foo::new;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CodeFlowTest {
|
||||
public static void main (String[] args) {
|
||||
String string;
|
||||
@@ -16,6 +18,7 @@ public class CodeFlowTest {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getString () throws SomeException {
|
||||
if (Math.random() < 0.5)
|
||||
throw new SomeException();
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ public class Normal17CompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testOnlyResourcesInResourceList4() { doTest() }
|
||||
|
||||
public void testMethodReferenceNoStatic() { doTest() }
|
||||
public void testMethodReferenceCallContext() { doTest() }
|
||||
|
||||
public void testResourceParentInResourceList() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
|
||||
@@ -116,6 +116,6 @@ public class DataFlowInspectionTest extends InspectionTestCase {
|
||||
public void testSwitchEnumCases() { doTest15(); }
|
||||
public void testTryWithResources() { doTest15(true); }
|
||||
|
||||
//public void testSCR15406() { doTest(); } // added by cdr, 2005
|
||||
public void testSCR15406() { doTest(); }
|
||||
//public void testIDEADEV11033() { doTest15(); } // added by max, 2007
|
||||
}
|
||||
|
||||
@@ -385,4 +385,55 @@
|
||||
<item name='javax.swing.RowSorter.SortKey SortKey(int, javax.swing.SortOrder) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setModel(javax.swing.table.TableModel) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setGridColor(java.awt.Color) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setDropMode(javax.swing.DropMode) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setColumnModel(javax.swing.table.TableColumnModel) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setSelectionModel(javax.swing.ListSelectionModel) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable JTable(java.lang.Object[][], java.lang.Object[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable JTable(java.lang.Object[][], java.lang.Object[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable java.awt.Dimension getIntercellSpacing()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void setIntercellSpacing(java.awt.Dimension) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable javax.swing.table.TableColumn getColumn(java.lang.Object) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void addColumn(javax.swing.table.TableColumn) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void removeColumn(javax.swing.table.TableColumn) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable int columnAtPoint(java.awt.Point) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable int rowAtPoint(java.awt.Point) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable java.awt.Rectangle getCellRect(int, int, boolean)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable java.lang.String getToolTipText(java.awt.event.MouseEvent) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='javax.swing.JTable void sorterChanged(javax.swing.event.RowSorterEvent) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DomJavaUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiClass findClass(String name, @NotNull DomElement element) {
|
||||
public static PsiClass findClass(@Nullable String name, @NotNull DomElement element) {
|
||||
XmlElement xmlElement = element.getXmlElement();
|
||||
if (xmlElement != null) {
|
||||
return findClass(name, xmlElement.getContainingFile(), element.getModule(), element.getResolveScope());
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jps.builders;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface BuildOutputConsumer {
|
||||
void registerOutputFile(String outputFilePath, Collection<String> sourceFiles) throws IOException;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package org.jetbrains.jps.builders.impl.logging;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class ProjectBuilderLoggerBase implements ProjectBuilderLogger {
|
||||
@Override
|
||||
public void logDeletedFiles(Collection<String> outputs) {
|
||||
if (outputs.isEmpty()) return;
|
||||
final String[] buffer = new String[outputs.size()];
|
||||
int i = 0;
|
||||
for (final String o : outputs) {
|
||||
buffer[i++] = o;
|
||||
}
|
||||
Arrays.sort(buffer);
|
||||
logLine("Cleaning output files:");
|
||||
for (final String o : buffer) {
|
||||
logLine(o);
|
||||
}
|
||||
logLine("End of files");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logCompiledFiles(Set<File> files, String builderName, final String description) throws IOException {
|
||||
logLine(description);
|
||||
final String[] buffer = new String[files.size()];
|
||||
int i = 0;
|
||||
for (final File f : files) {
|
||||
buffer[i++] = FileUtil.toSystemIndependentName(f.getCanonicalPath());
|
||||
}
|
||||
Arrays.sort(buffer);
|
||||
for (final String s : buffer) {
|
||||
logLine(s);
|
||||
}
|
||||
logLine("End of files");
|
||||
}
|
||||
|
||||
protected abstract void logLine(String message);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.jetbrains.jps.builders.impl.logging;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ProjectBuilderLoggerImpl extends ProjectBuilderLoggerBase {
|
||||
private static final Logger LOG = Logger.getInstance(ProjectBuilderLoggerImpl.class);
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return LOG.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logLine(final String message) {
|
||||
LOG.debug(message);
|
||||
}
|
||||
}
|
||||
+5
-12
@@ -1,24 +1,22 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
package org.jetbrains.jps.builders.logging;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLogger;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class BuildLoggingManager {
|
||||
public static final BuildLoggingManager DEFAULT = new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), new JavaBuilderLoggerImpl(),
|
||||
public static final BuildLoggingManager DEFAULT = new BuildLoggingManager(new ArtifactBuilderLoggerImpl(),
|
||||
new ProjectBuilderLoggerImpl());
|
||||
private ArtifactBuilderLogger myArtifactBuilderLogger;
|
||||
private JavaBuilderLogger myJavaBuilderLogger;
|
||||
private final ProjectBuilderLogger myProjectLogger;
|
||||
|
||||
public BuildLoggingManager(@NotNull ArtifactBuilderLogger artifactBuilderLogger, @NotNull JavaBuilderLogger logger, @NotNull ProjectBuilderLogger projectLogger) {
|
||||
public BuildLoggingManager(@NotNull ArtifactBuilderLogger artifactBuilderLogger,
|
||||
@NotNull ProjectBuilderLogger projectLogger) {
|
||||
myArtifactBuilderLogger = artifactBuilderLogger;
|
||||
myJavaBuilderLogger = logger;
|
||||
myProjectLogger = projectLogger;
|
||||
}
|
||||
|
||||
@@ -27,11 +25,6 @@ public class BuildLoggingManager {
|
||||
return myArtifactBuilderLogger;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JavaBuilderLogger getJavaBuilderLogger() {
|
||||
return myJavaBuilderLogger;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProjectBuilderLogger getProjectBuilderLogger() {
|
||||
return myProjectLogger;
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jetbrains.jps.builders.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface ProjectBuilderLogger {
|
||||
boolean isEnabled();
|
||||
|
||||
void logDeletedFiles(Collection<String> paths);
|
||||
|
||||
void logCompiledFiles(Set<File> files, String builderName, String description) throws IOException;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jps.builders.impl.BuildDataPathsImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildRootIndexImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetIndexImpl;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.jetbrains.jps.cmdline;
|
||||
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.BuildTargetIndex;
|
||||
import org.jetbrains.jps.incremental.BuildLoggingManager;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.incremental.CompilerEncodingConfiguration;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.*;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.FileDeletedEvent;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -128,12 +129,12 @@ public class FSOperations {
|
||||
}
|
||||
|
||||
static void markDirtyFiles(CompileContext context,
|
||||
ModuleBuildTarget target,
|
||||
BuildTarget<?> target,
|
||||
Timestamps timestamps, boolean forceMarkDirty,
|
||||
@Nullable THashSet<File> currentFiles) throws IOException {
|
||||
final ModuleExcludeIndex rootsIndex = context.getProjectDescriptor().getModuleExcludeIndex();
|
||||
markDirtyFiles(context, target, timestamps, forceMarkDirty, currentFiles,
|
||||
new HashSet<File>(rootsIndex.getModuleExcludes(target.getModule())));
|
||||
Set<File> excludes = target instanceof ModuleBuildTarget ? new HashSet<File>(rootsIndex.getModuleExcludes(((ModuleBuildTarget)target).getModule())) : Collections.<File>emptySet();
|
||||
markDirtyFiles(context, target, timestamps, forceMarkDirty, currentFiles, excludes);
|
||||
}
|
||||
|
||||
static void markDirtyFiles(CompileContext context, BuildTarget<?> target, Timestamps timestamps, boolean forceMarkDirty, @Nullable THashSet<File> currentFiles, final Set<File> excludes) throws IOException {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.BuildRunner;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
@@ -525,8 +526,7 @@ public class IncProjectBuilder {
|
||||
|
||||
BuildTarget<?> target = targets.iterator().next();
|
||||
if (target instanceof ModuleBuildTarget) {
|
||||
ModuleBuildTarget moduleBuildTarget = (ModuleBuildTarget)target;
|
||||
return runModuleLevelBuilders(context, new ModuleChunk(Collections.singleton(moduleBuildTarget)));
|
||||
return runModuleLevelBuilders(context, new ModuleChunk(Collections.singleton((ModuleBuildTarget)target)));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
@@ -563,7 +563,9 @@ public class IncProjectBuilder {
|
||||
}
|
||||
};
|
||||
//noinspection unchecked
|
||||
((TargetBuilder<R,T>)builder).build(target, context, holder);
|
||||
BuildOutputConsumerImpl outputConsumer = new BuildOutputConsumerImpl(target, context);
|
||||
((TargetBuilder<R,T>)builder).build(target, holder, outputConsumer, context);
|
||||
outputConsumer.fireFileGeneratedEvent();
|
||||
context.checkCanceled();
|
||||
}
|
||||
}
|
||||
@@ -757,9 +759,7 @@ public class IncProjectBuilder {
|
||||
FSOperations.processFilesToRecompile(context, chunk, processor);
|
||||
}
|
||||
};
|
||||
if (!context.isProjectRebuild()) {
|
||||
deleteOutputsOfDirtyFiles(context, dirtyFilesHolder);
|
||||
}
|
||||
deleteOutputsOfDirtyFiles(context, dirtyFilesHolder);
|
||||
|
||||
BUILDER_CATEGORY_LOOP:
|
||||
for (BuilderCategory category : BuilderCategory.values()) {
|
||||
@@ -833,6 +833,10 @@ public class IncProjectBuilder {
|
||||
|
||||
private static <R extends BuildRootDescriptor,T extends BuildTarget<R>>
|
||||
void deleteOutputsOfDirtyFiles(final CompileContext context, DirtyFilesHolder<R, T> dirtyFilesHolder) throws ProjectBuildException {
|
||||
if (context.isProjectRebuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
try {
|
||||
ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
|
||||
@@ -958,13 +962,12 @@ public class IncProjectBuilder {
|
||||
final Timestamps timestamps = pd.timestamps.getStorage();
|
||||
final BuildTargetConfiguration configuration = pd.getTargetsState().getTargetConfiguration(target);
|
||||
if (context.isProjectRebuild() || configuration.isTargetDirty() || context.getScope().isRecompilationForced(target)) {
|
||||
clearOutputFiles(context, target);
|
||||
FSOperations.markDirtyFiles(context, target, timestamps, true, null, Collections.<File>emptySet());
|
||||
configuration.save();
|
||||
}
|
||||
else if (context.isMake()) {
|
||||
if (pd.fsState.markInitialScanPerformed(target)) {
|
||||
FSOperations.markDirtyFiles(context, target, timestamps, false, null, Collections.<File>emptySet());
|
||||
}
|
||||
else if (pd.fsState.markInitialScanPerformed(target)) {
|
||||
FSOperations.markDirtyFiles(context, target, timestamps, false, null, Collections.<File>emptySet());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,19 +995,21 @@ public class IncProjectBuilder {
|
||||
forceMarkDirty = true;
|
||||
}
|
||||
}
|
||||
initModuleFSState(context, target, forceMarkDirty);
|
||||
initTargetFSState(context, target, forceMarkDirty);
|
||||
updateOutputRootsLayout(context, target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// forced compilation mode
|
||||
if (context.getScope().isRecompilationForced(target)) {
|
||||
initModuleFSState(context, target, true);
|
||||
initTargetFSState(context, target, true);
|
||||
updateOutputRootsLayout(context, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void initModuleFSState(CompileContext context, ModuleBuildTarget target, final boolean forceMarkDirty) throws IOException {
|
||||
private static void initTargetFSState(CompileContext context, BuildTarget<?> target, final boolean forceMarkDirty) throws IOException {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
final Timestamps timestamps = pd.timestamps.getStorage();
|
||||
final THashSet<File> currentFiles = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
@@ -1022,8 +1027,6 @@ public class IncProjectBuilder {
|
||||
fsState.registerDeleted(target, file, timestamps);
|
||||
}
|
||||
}
|
||||
|
||||
updateOutputRootsLayout(context, target);
|
||||
}
|
||||
|
||||
private static void updateOutputRootsLayout(CompileContext context, ModuleBuildTarget target) throws IOException {
|
||||
@@ -1119,4 +1122,34 @@ public class IncProjectBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
private static class BuildOutputConsumerImpl implements BuildOutputConsumer {
|
||||
private final BuildTarget<?> myTarget;
|
||||
private final CompileContext myContext;
|
||||
private FileGeneratedEvent myFileGeneratedEvent;
|
||||
private File myOutputDir;
|
||||
|
||||
public BuildOutputConsumerImpl(BuildTarget<?> target, CompileContext context) {
|
||||
myTarget = target;
|
||||
myContext = context;
|
||||
myFileGeneratedEvent = new FileGeneratedEvent();
|
||||
myOutputDir = myTarget.getOutputDir(myContext.getProjectDescriptor().dataManager.getDataPaths());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOutputFile(String outputFilePath, Collection<String> sourceFiles) throws IOException {
|
||||
String relativePath = FileUtil.getRelativePath(myOutputDir, new File(outputFilePath));
|
||||
if (myOutputDir != null && relativePath != null) {
|
||||
myFileGeneratedEvent.add(myOutputDir.getAbsolutePath(), relativePath);
|
||||
}
|
||||
for (String sourceFile : sourceFiles) {
|
||||
myContext.getProjectDescriptor().dataManager.getSourceToOutputMap(myTarget).appendOutput(sourceFile, outputFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
public void fireFileGeneratedEvent() {
|
||||
if (!myFileGeneratedEvent.getPaths().isEmpty()) {
|
||||
myContext.processMessage(myFileGeneratedEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface ProjectBuilderLogger {
|
||||
boolean isEnabled();
|
||||
void logDeletedFiles(Collection<String> paths);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ProjectBuilderLoggerImpl implements ProjectBuilderLogger {
|
||||
private static final Logger LOG = Logger.getInstance(ProjectBuilderLoggerImpl.class);
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return LOG.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logDeletedFiles(Collection<String> outputs) {
|
||||
if (outputs.isEmpty()) return;
|
||||
final String[] buffer = new String[outputs.size()];
|
||||
int i = 0;
|
||||
for (final String o : outputs) {
|
||||
buffer[i++] = o;
|
||||
}
|
||||
Arrays.sort(buffer);
|
||||
logLine("Cleaning output files:");
|
||||
for (final String o : buffer) {
|
||||
logLine(o);
|
||||
}
|
||||
logLine("End of files");
|
||||
}
|
||||
|
||||
protected void logLine(final String message) {
|
||||
LOG.debug(message);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.BuildTargetType;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
@@ -24,7 +21,7 @@ public abstract class TargetBuilder<R extends BuildRootDescriptor, T extends Bui
|
||||
return myTargetTypes;
|
||||
}
|
||||
|
||||
public abstract void build(@NotNull T target, @NotNull CompileContext context, DirtyFilesHolder<R, T> holder)
|
||||
throws ProjectBuildException, IOException;
|
||||
public abstract void build(@NotNull T target, @NotNull DirtyFilesHolder<R, T> holder, @NotNull BuildOutputConsumer outputConsumer,
|
||||
@NotNull CompileContext context) throws ProjectBuildException, IOException;
|
||||
|
||||
}
|
||||
|
||||
+4
-10
@@ -11,10 +11,7 @@ import org.jetbrains.jps.incremental.IncProjectBuilder;
|
||||
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.artifacts.instructions.SourceFileFilter;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.BuildTargetConfiguration;
|
||||
import org.jetbrains.jps.incremental.storage.CompositeStorageOwner;
|
||||
import org.jetbrains.jps.incremental.storage.StorageOwner;
|
||||
import org.jetbrains.jps.incremental.storage.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -32,13 +29,10 @@ public class ArtifactSourceFilesState extends CompositeStorageOwner {
|
||||
private File myOutSrcMappingsFile;
|
||||
private final ProjectDescriptor myProjectDescriptor;
|
||||
|
||||
public ArtifactSourceFilesState(ArtifactBuildTarget target,
|
||||
ProjectDescriptor projectDescriptor,
|
||||
File mappingsDir) {
|
||||
int artifactId = projectDescriptor.getTargetsState().getBuildTargetId(target);
|
||||
public ArtifactSourceFilesState(ArtifactBuildTarget target, ProjectDescriptor projectDescriptor) {
|
||||
myProjectDescriptor = projectDescriptor;
|
||||
myTarget = target;
|
||||
myOutSrcMappingsFile = new File(new File(mappingsDir, String.valueOf(artifactId)), "out-src");
|
||||
myOutSrcMappingsFile = new File(projectDescriptor.dataManager.getDataPaths().getTargetDataRoot(target), "out-src" + File.separator + "data");
|
||||
}
|
||||
|
||||
public ArtifactOutputToSourceMapping getOrCreateOutSrcMapping() throws IOException {
|
||||
@@ -58,7 +52,7 @@ public class ArtifactSourceFilesState extends CompositeStorageOwner {
|
||||
BuildTargetConfiguration configuration = myProjectDescriptor.getTargetsState().getTargetConfiguration(myTarget);
|
||||
if (context.isProjectRebuild() || configuration.isTargetDirty() || context.getScope().isRecompilationForced(myTarget)) {
|
||||
IncProjectBuilder.clearOutputFiles(context, myTarget);
|
||||
myProjectDescriptor.dataManager.getSourceToOutputMap(myTarget).clean();
|
||||
((SourceToOutputMappingImpl)myProjectDescriptor.dataManager.getSourceToOutputMap(myTarget)).clean();
|
||||
getOrCreateOutSrcMapping().clean();
|
||||
markDirtyFiles(dataManager, null, true, context);
|
||||
configuration.save();
|
||||
|
||||
+2
-7
@@ -1,11 +1,9 @@
|
||||
package org.jetbrains.jps.incremental.artifacts;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.storage.CompositeStorageOwner;
|
||||
import org.jetbrains.jps.incremental.storage.StorageOwner;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -15,17 +13,15 @@ import java.util.Map;
|
||||
*/
|
||||
public class ArtifactsBuildData extends CompositeStorageOwner {
|
||||
private Map<ArtifactBuildTarget, ArtifactSourceFilesState> myArtifactState;
|
||||
private final File myMappingsDir;
|
||||
|
||||
public ArtifactsBuildData(File artifactsDataDir) throws IOException {
|
||||
public ArtifactsBuildData() throws IOException {
|
||||
myArtifactState = new HashMap<ArtifactBuildTarget, ArtifactSourceFilesState>();
|
||||
myMappingsDir = new File(artifactsDataDir, "mappings");
|
||||
}
|
||||
|
||||
public ArtifactSourceFilesState getOrCreateState(ArtifactBuildTarget target, ProjectDescriptor projectDescriptor) {
|
||||
ArtifactSourceFilesState state = myArtifactState.get(target);
|
||||
if (state == null) {
|
||||
state = new ArtifactSourceFilesState(target, projectDescriptor, myMappingsDir);
|
||||
state = new ArtifactSourceFilesState(target, projectDescriptor);
|
||||
myArtifactState.put(target, state);
|
||||
}
|
||||
return state;
|
||||
@@ -44,7 +40,6 @@ public class ArtifactsBuildData extends CompositeStorageOwner {
|
||||
}
|
||||
}
|
||||
myArtifactState.clear();
|
||||
FileUtil.delete(myMappingsDir);
|
||||
if (exc != null) {
|
||||
throw exc;
|
||||
}
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildOutputConsumer;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
@@ -38,8 +39,8 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactRootDescriptor, Ar
|
||||
|
||||
@Override
|
||||
public void build(@NotNull ArtifactBuildTarget target,
|
||||
@NotNull CompileContext context,
|
||||
DirtyFilesHolder<ArtifactRootDescriptor, ArtifactBuildTarget> holder) throws ProjectBuildException {
|
||||
@NotNull DirtyFilesHolder<ArtifactRootDescriptor, ArtifactBuildTarget> holder,
|
||||
@NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException {
|
||||
JpsArtifact artifact = target.getArtifact();
|
||||
if (StringUtil.isEmpty(artifact.getOutputPath())) {
|
||||
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "Cannot build '" + artifact.getName() + "' artifact: output path is not specified"));
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
@@ -234,13 +235,13 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
|
||||
final ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
|
||||
if (logger.isEnabled() && context.isMake()) {
|
||||
if (filesToCompile.size() > 0) {
|
||||
logFiles(filesToCompile, logger, "Compiling files:");
|
||||
logger.logCompiledFiles(filesToCompile, BUILDER_NAME, "Compiling files:");
|
||||
}
|
||||
if (!formsToCompile.isEmpty()) {
|
||||
logFiles(formsToCompile, logger, "Compiling forms:");
|
||||
logger.logCompiledFiles(formsToCompile, FORMS_BUILDER_NAME, "Compiling forms:");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,20 +262,6 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void logFiles(Set<File> files, JavaBuilderLogger logger, final String description) throws IOException {
|
||||
logger.log(description);
|
||||
final String[] buffer = new String[files.size()];
|
||||
int i = 0;
|
||||
for (final File f : files) {
|
||||
buffer[i++] = FileUtil.toSystemIndependentName(f.getCanonicalPath());
|
||||
}
|
||||
Arrays.sort(buffer);
|
||||
for (final String s : buffer) {
|
||||
logger.log(s);
|
||||
}
|
||||
logger.log("End of files");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldHonorFileEncodingForCompilation(File file) {
|
||||
return JAVA_SOURCES_FILTER.accept(file) || FORM_SOURCES_FILTER.accept(file);
|
||||
@@ -1138,8 +1125,12 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final JavaFileObject source = diagnostic.getSource();
|
||||
final File sourceFile = source != null ? Utils.convertToFile(source.toUri()) : null;
|
||||
final String srcPath = sourceFile != null ? FileUtil.toSystemIndependentName(sourceFile.getPath()) : null;
|
||||
String message = diagnostic.getMessage(Locale.US);
|
||||
if (Utils.IS_TEST_MODE) {
|
||||
LOG.info(message);
|
||||
}
|
||||
myContext.processMessage(
|
||||
new CompilerMessage(BUILDER_NAME, kind, diagnostic.getMessage(Locale.US), srcPath, diagnostic.getStartPosition(),
|
||||
new CompilerMessage(BUILDER_NAME, kind, message, srcPath, diagnostic.getStartPosition(),
|
||||
diagnostic.getEndPosition(), diagnostic.getPosition(), diagnostic.getLineNumber(),
|
||||
diagnostic.getColumnNumber()));
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package org.jetbrains.jps.incremental.java;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JavaBuilderLogger {
|
||||
void log(String line);
|
||||
boolean isEnabled();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.jetbrains.jps.incremental.java;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaBuilderLoggerImpl implements JavaBuilderLogger {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl");
|
||||
|
||||
@Override
|
||||
public void log(String line) {
|
||||
LOG.debug(line);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return LOG.isDebugEnabled();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactsBuildData;
|
||||
|
||||
import java.io.*;
|
||||
@@ -19,7 +20,7 @@ import java.util.Map;
|
||||
* Date: 10/7/11
|
||||
*/
|
||||
public class BuildDataManager implements StorageOwner {
|
||||
private static final int VERSION = 14;
|
||||
private static final int VERSION = 15;
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.storage.BuildDataManager");
|
||||
private static final String SRC_TO_FORM_STORAGE = "src-form";
|
||||
private static final String MAPPINGS_STORAGE = "mappings";
|
||||
@@ -41,7 +42,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
mySrcToFormMap = new OneToManyPathsMapping(new File(getSourceToFormsRoot(), "data"));
|
||||
myOutputRootsLayout = new ModuleOutputRootsLayout(new File(getOutputsLayoutRoot(), "data"));
|
||||
myMappings = new Mappings(getMappingsRoot(), useMemoryTempCaches);
|
||||
myArtifactsBuildData = new ArtifactsBuildData(new File(dataPaths.getDataStorageRoot(), "artifacts"));
|
||||
myArtifactsBuildData = new ArtifactsBuildData();
|
||||
myVersionFile = new File(myDataPaths.getDataStorageRoot(), "version.dat");
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
return new File(myDataPaths.getDataStorageRoot(), "output-roots");
|
||||
}
|
||||
|
||||
public SourceToOutputMappingImpl getSourceToOutputMap(final BuildTarget<?> target) throws IOException {
|
||||
public SourceToOutputMapping getSourceToOutputMap(final BuildTarget<?> target) throws IOException {
|
||||
SourceToOutputMappingImpl mapping;
|
||||
synchronized (mySourceToOutputLock) {
|
||||
mapping = mySourceToOutputs.get(target);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class SourceToOutputMappingImpl implements SourceToOutputMapping {
|
||||
|
||||
@Override
|
||||
public void setOutput(@NotNull String srcPath, @NotNull String outputPath) throws IOException {
|
||||
myMapping.update(outputPath, outputPath);
|
||||
myMapping.update(srcPath, outputPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,7 +78,8 @@ public class TimestampStorage extends AbstractStateStorage<File, TimestampStorag
|
||||
remove(file);
|
||||
}
|
||||
else {
|
||||
ArrayUtil.remove(state, i);
|
||||
TimestampPerTarget[] newState = ArrayUtil.remove(state, i);
|
||||
update(file, newState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,14 @@ import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.jps.builders.CompileScopeTestBuilder;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.BuildResult;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.CompileScopeTestBuilder;
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerBase;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
@@ -37,10 +35,9 @@ import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author db
|
||||
@@ -173,8 +170,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
|
||||
protected BuildResult doTestBuild(int makesCount) {
|
||||
StringBuilder log = new StringBuilder();
|
||||
String rootPath = FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) + "/";
|
||||
final TestJavaBuilderLogger builderLogger = new TestJavaBuilderLogger(rootPath, log);
|
||||
final ProjectDescriptor pd = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(), builderLogger,
|
||||
final ProjectDescriptor pd = createProjectDescriptor(new BuildLoggingManager(new ArtifactBuilderLoggerImpl(),
|
||||
new TestProjectBuilderLogger(rootPath, log)));
|
||||
try {
|
||||
doBuild(pd, CompileScopeTestBuilder.rebuild().allModules()).assertSuccessful();
|
||||
@@ -238,10 +234,6 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private static CompileScope createAllModulesScope(final boolean forcedCompilation) {
|
||||
return new CompileScopeImpl(forcedCompilation, JavaModuleBuildTargetType.ALL_TYPES, Collections.<BuildTarget<?>>emptySet(), Collections.<BuildTarget<?>, Set<File>>emptyMap());
|
||||
}
|
||||
|
||||
private JpsSdk<JpsDummyElement> getOrCreateJdk() {
|
||||
if (myJdk == null) {
|
||||
myJdk = addJdk("IDEA jdk");
|
||||
@@ -259,27 +251,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
|
||||
module.addSourceRoot(getUrl(testRootRelativePath), JavaSourceRootType.TEST_SOURCE);
|
||||
}
|
||||
|
||||
private static class TestJavaBuilderLogger implements JavaBuilderLogger {
|
||||
private final String myRoot;
|
||||
private final StringBuilder myLog;
|
||||
|
||||
public TestJavaBuilderLogger(String root, final StringBuilder log) {
|
||||
myRoot = root;
|
||||
myLog = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String line) {
|
||||
myLog.append(StringUtil.trimStart(line, myRoot)).append('\n');
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestProjectBuilderLogger extends ProjectBuilderLoggerImpl {
|
||||
private static class TestProjectBuilderLogger extends ProjectBuilderLoggerBase {
|
||||
private final String myRoot;
|
||||
private StringBuilder myLog;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.builders.impl.BuildDataPathsImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildRootIndexImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetIndexImpl;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
|
||||
+3
-4
@@ -23,9 +23,8 @@ import org.jetbrains.jps.builders.BuildResult;
|
||||
import org.jetbrains.jps.builders.CompileScopeTestBuilder;
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.BuildLoggingManager;
|
||||
import org.jetbrains.jps.incremental.ProjectBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
@@ -105,7 +104,7 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
|
||||
protected BuildResult doBuild(CompileScopeTestBuilder scope) {
|
||||
BuildResult result;
|
||||
ProjectDescriptor descriptor = createProjectDescriptor(new BuildLoggingManager(myArtifactBuilderLogger, new JavaBuilderLoggerImpl(), new ProjectBuilderLoggerImpl()));
|
||||
ProjectDescriptor descriptor = createProjectDescriptor(new BuildLoggingManager(myArtifactBuilderLogger, new ProjectBuilderLoggerImpl()));
|
||||
try {
|
||||
myArtifactBuilderLogger.clear();
|
||||
result = doBuild(descriptor, scope);
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.fileTypes;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,7 @@ public interface FileContent extends UserDataHolder {
|
||||
|
||||
byte[] getContent();
|
||||
|
||||
@NotNull
|
||||
CharSequence getContentAsText();
|
||||
|
||||
Project getProject();
|
||||
|
||||
@@ -179,6 +179,7 @@ public final class FileContentImpl extends UserDataHolderBase implements FileCon
|
||||
return myContent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequence getContentAsText() {
|
||||
if (myFileType.isBinary()) {
|
||||
|
||||
+1
@@ -282,6 +282,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
@NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptionNode.extractHighlightedText(description, psiElement): "") , " #loc ", " ");
|
||||
|
||||
Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
|
||||
if (element == null) return;
|
||||
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
|
||||
problemClassElement.addContent(getDisplayName());
|
||||
if (refEntity instanceof RefElement){
|
||||
|
||||
@@ -212,6 +212,7 @@ public class RefManagerImpl extends RefManager {
|
||||
final RefElement refElement = (RefElement)refEntity;
|
||||
final SmartPsiElementPointer pointer = refElement.getPointer();
|
||||
PsiFile psiFile = pointer.getContainingFile();
|
||||
if (psiFile == null) return null;
|
||||
|
||||
Element fileElement = new Element("file");
|
||||
Element lineElement = new Element("line");
|
||||
|
||||
+20
-21
@@ -210,33 +210,32 @@ public abstract class PlatformIdTableBuilding {
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<TodoIndexEntry, Integer> map(final FileContent inputData) {
|
||||
final CharSequence chars = inputData.getContentAsText();
|
||||
|
||||
String chars = inputData.getContentAsText().toString(); // matching strings is faster than HeapCharBuffer
|
||||
|
||||
final IndexPattern[] indexPatterns = IndexPatternUtil.getIndexPatterns();
|
||||
if (indexPatterns.length > 0) {
|
||||
final OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
for (IndexPattern indexPattern : indexPatterns) {
|
||||
Pattern pattern = indexPattern.getPattern();
|
||||
if (pattern != null) {
|
||||
Matcher matcher = pattern.matcher(chars);
|
||||
while (matcher.find()) {
|
||||
if (matcher.start() != matcher.end()) {
|
||||
occurrenceConsumer.incTodoOccurrence(indexPattern);
|
||||
}
|
||||
if (indexPatterns.length <= 0) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
for (IndexPattern indexPattern : indexPatterns) {
|
||||
Pattern pattern = indexPattern.getPattern();
|
||||
if (pattern != null) {
|
||||
Matcher matcher = pattern.matcher(chars);
|
||||
while (matcher.find()) {
|
||||
if (matcher.start() != matcher.end()) {
|
||||
occurrenceConsumer.incTodoOccurrence(indexPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<TodoIndexEntry, Integer> map = new HashMap<TodoIndexEntry, Integer>();
|
||||
for (IndexPattern indexPattern : indexPatterns) {
|
||||
final int count = occurrenceConsumer.getOccurrenceCount(indexPattern);
|
||||
if (count > 0) {
|
||||
map.put(new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), count);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
Map<TodoIndexEntry, Integer> map = new HashMap<TodoIndexEntry, Integer>();
|
||||
for (IndexPattern indexPattern : indexPatterns) {
|
||||
final int count = occurrenceConsumer.getOccurrenceCount(indexPattern);
|
||||
if (count > 0) {
|
||||
map.put(new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), count);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class InjectedSelfElementInfo extends SelfElementInfo {
|
||||
}
|
||||
};
|
||||
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(hostFile.getProject());
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
|
||||
Document document = documentManager.getDocument(hostFile);
|
||||
if (document != null && documentManager.isUncommited(document)) {
|
||||
for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(hostFile)) {
|
||||
|
||||
@@ -52,13 +52,13 @@ public class TextFieldWithAutoCompletion<T> extends LanguageTextField {
|
||||
|
||||
public TextFieldWithAutoCompletion() {
|
||||
// For UI designer
|
||||
this(null, null, false);
|
||||
this(null, null, false, null);
|
||||
}
|
||||
|
||||
public TextFieldWithAutoCompletion(final Project project,
|
||||
@Nullable final TextFieldWithAutoCompletionListProvider<T> provider,
|
||||
final boolean showAutocompletionIsAvailableHint) {
|
||||
super(PlainTextLanguage.INSTANCE, project, "");
|
||||
final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
|
||||
super(PlainTextLanguage.INSTANCE, project, text == null ? "" : text);
|
||||
|
||||
myShowAutocompletionIsAvailableHint = showAutocompletionIsAvailableHint;
|
||||
|
||||
@@ -70,8 +70,9 @@ public class TextFieldWithAutoCompletion<T> extends LanguageTextField {
|
||||
public static TextFieldWithAutoCompletion<String> create(final Project project,
|
||||
@NotNull final Collection<String> items,
|
||||
@Nullable final Icon icon,
|
||||
final boolean showAutocompletionIsAvailableHint) {
|
||||
return new TextFieldWithAutoCompletion<String>(project, new StringsCompletionProvider(items, icon), showAutocompletionIsAvailableHint);
|
||||
final boolean showAutocompletionIsAvailableHint, @Nullable final String text) {
|
||||
return new TextFieldWithAutoCompletion<String>(project, new StringsCompletionProvider(items, icon), showAutocompletionIsAvailableHint,
|
||||
text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.fileEditor;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface SelectedFileEditorProvider {
|
||||
ExtensionPointName<SelectedFileEditorProvider> EP_SELECTED_FILE_EDITOR_PROVIDER =
|
||||
new ExtensionPointName<SelectedFileEditorProvider>("com.intellij.selectedFileEditorProvider");
|
||||
|
||||
@Nullable
|
||||
FileEditorProvider getSelectedProvider(Project project, VirtualFile file);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.keymap;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class KeymapManager {
|
||||
@@ -33,7 +34,7 @@ public abstract class KeymapManager {
|
||||
return ApplicationManager.getApplication().getComponent(KeymapManager.class);
|
||||
}
|
||||
|
||||
public abstract void addKeymapManagerListener(KeymapManagerListener listener);
|
||||
public abstract void addKeymapManagerListener(@NotNull KeymapManagerListener listener);
|
||||
|
||||
public abstract void removeKeymapManagerListener(KeymapManagerListener listener);
|
||||
public abstract void removeKeymapManagerListener(@NotNull KeymapManagerListener listener);
|
||||
}
|
||||
|
||||
@@ -30,20 +30,20 @@ import javax.swing.*;
|
||||
|
||||
public final class ShadowAction implements Disposable {
|
||||
|
||||
private AnAction myAction;
|
||||
private final AnAction myAction;
|
||||
private AnAction myCopyFromAction;
|
||||
private JComponent myComponent;
|
||||
private final JComponent myComponent;
|
||||
|
||||
private KeymapManagerListener myKeymapManagerListener;
|
||||
private final KeymapManagerListener myKeymapManagerListener;
|
||||
|
||||
private ShortcutSet myShortcutSet;
|
||||
private String myActionId;
|
||||
|
||||
private Keymap.Listener myKeymapListener;
|
||||
private final Keymap.Listener myKeymapListener;
|
||||
private Keymap myKeymap;
|
||||
|
||||
private Presentation myPresentation;
|
||||
private UiNotifyConnector myUiNotify;
|
||||
private final UiNotifyConnector myUiNotify;
|
||||
|
||||
public ShadowAction(AnAction action, AnAction copyFromAction, JComponent component, Presentation presentation) {
|
||||
this(action, copyFromAction, component);
|
||||
@@ -60,6 +60,7 @@ public final class ShadowAction implements Disposable {
|
||||
myAction.getTemplatePresentation().copyFrom(copyFromAction.getTemplatePresentation());
|
||||
|
||||
myKeymapListener = new Keymap.Listener() {
|
||||
@Override
|
||||
public void onShortcutChanged(final String actionId) {
|
||||
if (myActionId == null || actionId.equals(myActionId)) {
|
||||
rebound();
|
||||
@@ -68,16 +69,19 @@ public final class ShadowAction implements Disposable {
|
||||
};
|
||||
|
||||
myKeymapManagerListener = new KeymapManagerListener() {
|
||||
@Override
|
||||
public void activeKeymapChanged(final Keymap keymap) {
|
||||
rebound();
|
||||
}
|
||||
};
|
||||
|
||||
myUiNotify = new UiNotifyConnector(myComponent, new Activatable() {
|
||||
@Override
|
||||
public void showNotify() {
|
||||
_connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideNotify() {
|
||||
disconnect();
|
||||
}
|
||||
@@ -140,14 +144,15 @@ public final class ShadowAction implements Disposable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
unregisterAll();
|
||||
myUiNotify.dispose();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private static @Nullable
|
||||
KeymapManager getKeymapManager() {
|
||||
@Nullable
|
||||
private static KeymapManager getKeymapManager() {
|
||||
if (ApplicationManager.getApplication().isDisposed()) return null;
|
||||
return KeymapManager.getInstance();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class QuickAccessSettings implements ApplicationComponent, KeymapManagerListener, Disposable {
|
||||
private Set<Integer> myModifierVks = new HashSet<Integer>();
|
||||
private final Set<Integer> myModifierVks = new HashSet<Integer>();
|
||||
private Keymap myKeymap;
|
||||
@NonNls public static final String SWITCH_UP = "SwitchUp";
|
||||
@NonNls public static final String SWITCH_DOWN = "SwitchDown";
|
||||
|
||||
+58
-8
@@ -31,7 +31,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
@@ -61,7 +60,7 @@ import java.util.List;
|
||||
public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionToolbarImpl");
|
||||
|
||||
private static List<ActionToolbarImpl> ourToolbars = new LinkedList<ActionToolbarImpl>();
|
||||
private static final List<ActionToolbarImpl> ourToolbars = new LinkedList<ActionToolbarImpl>();
|
||||
public static void updateAllToolbarsImmediately() {
|
||||
for (ActionToolbarImpl toolbar : new ArrayList<ActionToolbarImpl>(ourToolbars)) {
|
||||
toolbar.updateActionsImmediately();
|
||||
@@ -90,7 +89,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
private int myOrientation;
|
||||
private final ActionGroup myActionGroup;
|
||||
private final String myPlace;
|
||||
@SuppressWarnings({"FieldCanBeLocal"}) private final MyKeymapManagerListener myKeymapManagerListener;
|
||||
private final MyKeymapManagerListener myKeymapManagerListener;
|
||||
private List<AnAction> myNewVisibleActions;
|
||||
protected List<AnAction> myVisibleActions;
|
||||
private final PresentationFactory myPresentationFactory;
|
||||
@@ -125,8 +124,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
private boolean myReservePlaceAutoPopupIcon = true;
|
||||
private boolean myAddSeparatorFirst;
|
||||
|
||||
private WeakTimerListener myWeakTimerListener;
|
||||
@SuppressWarnings({"FieldCanBeLocal"}) private ActionToolbarImpl.MyTimerListener myTimerListener;
|
||||
private final WeakTimerListener myWeakTimerListener;
|
||||
@SuppressWarnings({"FieldCanBeLocal"}) private final ActionToolbarImpl.MyTimerListener myTimerListener;
|
||||
public ActionToolbarImpl(final String place,
|
||||
@NotNull final ActionGroup actionGroup,
|
||||
final boolean horizontal,
|
||||
@@ -174,7 +173,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
updateActions(updateActionsNow, false, false);
|
||||
|
||||
//
|
||||
keymapManager.addKeymapManagerListener(new WeakKeymapManagerListener(keymapManager, myKeymapManagerListener));
|
||||
keymapManager.addWeakListener(myKeymapManagerListener);
|
||||
myTimerListener = new MyTimerListener();
|
||||
myWeakTimerListener = new WeakTimerListener(actionManager, myTimerListener);
|
||||
// If the panel doesn't handle mouse event then it will be passed to its parent.
|
||||
@@ -193,7 +192,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
private boolean doMacEnhancementsForMainToolbar() {
|
||||
return (UIUtil.isUnderAquaLookAndFeel() && (ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || myForceUseMacEnhancements));
|
||||
return UIUtil.isUnderAquaLookAndFeel() && (ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || myForceUseMacEnhancements);
|
||||
}
|
||||
|
||||
public void setForceUseMacEnhancements(boolean useMacEnhancements) {
|
||||
@@ -210,16 +209,20 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
ourToolbars.remove(this);
|
||||
myActionManager.removeTimerListener(myWeakTimerListener);
|
||||
myActionManager.removeTransparentTimerListener(myWeakTimerListener);
|
||||
myKeymapManager.removeWeakListener(myKeymapManagerListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPolicy() {
|
||||
return myLayoutPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutPolicy(final int layoutPolicy) {
|
||||
if (layoutPolicy != NOWRAP_LAYOUT_POLICY && layoutPolicy != WRAP_LAYOUT_POLICY && layoutPolicy != AUTO_LAYOUT_POLICY) {
|
||||
throw new IllegalArgumentException("wrong layoutPolicy: " + layoutPolicy);
|
||||
@@ -227,6 +230,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
myLayoutPolicy = layoutPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
if (doMacEnhancementsForMainToolbar()) {
|
||||
final Rectangle r = getBounds();
|
||||
@@ -308,6 +312,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
final ActionButton actionButton = new ActionButton(action, presentation, place, minimumSize) {
|
||||
@Override
|
||||
protected DataContext getDataContext() {
|
||||
return getToolbarDataContext();
|
||||
}
|
||||
@@ -320,6 +325,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
return createToolbarButton(action, myMinimalMode ? myMinimalButtonLook : myDecorateButtons ? new MacToolbarDecoratorButtonLook() : myButtonLook, myPlace, myPresentationFactory.getPresentation(action), myMinimumButtonSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
if (!isValid()) {
|
||||
calculateBounds(getSize(), myComponentBounds);
|
||||
@@ -332,6 +338,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
if (!isValid()) {
|
||||
calculateBounds(getSize(), myComponentBounds);
|
||||
@@ -359,6 +366,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
/**
|
||||
* @return maximum button height
|
||||
*/
|
||||
@Override
|
||||
public int getMaxButtonHeight() {
|
||||
int height = 0;
|
||||
for (int i = 0; i < getComponentCount(); i++) {
|
||||
@@ -684,6 +692,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
final ArrayList<Rectangle> bounds = new ArrayList<Rectangle>();
|
||||
calculateBounds(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), bounds);
|
||||
@@ -716,6 +725,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
return new Dimension(dimension.width + i.left + i.right, dimension.height + i.top + i.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
if (myLayoutPolicy == AUTO_LAYOUT_POLICY) {
|
||||
final Insets i = getInsets();
|
||||
@@ -738,10 +748,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return mySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
final Insets insets = getInsets();
|
||||
if (UIUtil.isUnderAquaBasedLookAndFeel()) {
|
||||
@@ -768,6 +780,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
private final class MyKeymapManagerListener implements KeymapManagerListener {
|
||||
@Override
|
||||
public void activeKeymapChanged(final Keymap keymap) {
|
||||
final int componentCount = getComponentCount();
|
||||
for (int i = 0; i < componentCount; i++) {
|
||||
@@ -781,10 +794,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
private final class MyTimerListener implements TimerListener {
|
||||
|
||||
@Override
|
||||
public ModalityState getModalityState() {
|
||||
return ModalityState.stateForComponent(ActionToolbarImpl.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isShowing()) {
|
||||
return;
|
||||
@@ -811,6 +826,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTheSameSize(final boolean value) {
|
||||
if (myAdjustTheSameSize == value) {
|
||||
return;
|
||||
@@ -819,6 +835,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinimumButtonSize(@NotNull final Dimension size) {
|
||||
myMinimumButtonSize = size;
|
||||
for (int i = getComponentCount() - 1; i >= 0; i--) {
|
||||
@@ -831,6 +848,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(final int orientation) {
|
||||
if (SwingConstants.HORIZONTAL != orientation && SwingConstants.VERTICAL != orientation) {
|
||||
throw new IllegalArgumentException("wrong orientation: " + orientation);
|
||||
@@ -838,6 +856,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
myOrientation = orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActionsImmediately() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
updateActions(true, false, false);
|
||||
@@ -845,6 +864,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
private void updateActions(boolean now, final boolean transparentOnly, final boolean forced) {
|
||||
final IdRunnable updateRunnable = new IdRunnable(this) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
@@ -902,6 +922,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
fm.doWhenFocusSettlesDown(updateRunnable);
|
||||
} else {
|
||||
UiNotifyConnector.doWhenFirstShown(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fm.doWhenFocusSettlesDown(updateRunnable);
|
||||
}
|
||||
@@ -916,11 +937,13 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
return !myVisibleActions.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTargetComponent(final JComponent component) {
|
||||
myTargetComponent = component;
|
||||
|
||||
if (myTargetComponent != null && myTargetComponent.isVisible()) {
|
||||
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateActions(false, false, false);
|
||||
}
|
||||
@@ -928,6 +951,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataContext getToolbarDataContext() {
|
||||
return getDataContext();
|
||||
}
|
||||
@@ -936,6 +960,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
return myTargetComponent != null ? myDataManager.getDataContext(myTargetComponent) : ((DataManagerImpl)myDataManager).getDataContextTest(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processMouseMotionEvent(final MouseEvent e) {
|
||||
super.processMouseMotionEvent(e);
|
||||
|
||||
@@ -944,6 +969,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
if (myAutoPopupRec != null && myAutoPopupRec.contains(e.getPoint())) {
|
||||
IdeFocusManager.getInstance(null).doWhenFocusSettlesDown(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showAutoPopup();
|
||||
}
|
||||
@@ -967,10 +993,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
PopupToolbar popupToolbar = new PopupToolbar(myPlace, group, true, myDataManager, myActionManager, myKeymapManager, this) {
|
||||
@Override
|
||||
protected void onOtherActionPerformed() {
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataContext getDataContext() {
|
||||
return ActionToolbarImpl.this.getDataContext();
|
||||
}
|
||||
@@ -994,6 +1022,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
.setCancelOnClickOutside(true)
|
||||
.setCancelOnOtherWindowOpen(true)
|
||||
.setCancelCallback(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
final boolean toClose = myActionManager.isActionPopupStackEmpty();
|
||||
if (toClose) {
|
||||
@@ -1003,6 +1032,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
})
|
||||
.setCancelOnMouseOutCallback(new MouseChecker() {
|
||||
@Override
|
||||
public boolean check(final MouseEvent event) {
|
||||
return myAutoPopupRec != null &&
|
||||
myActionManager.isActionPopupStackEmpty() &&
|
||||
@@ -1011,6 +1041,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
});
|
||||
|
||||
builder.addListener(new JBPopupAdapter() {
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
processClosed();
|
||||
}
|
||||
@@ -1039,24 +1070,29 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
final Window window = SwingUtilities.getWindowAncestor(this);
|
||||
if (window != null) {
|
||||
final ComponentAdapter componentAdapter = new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(final ComponentEvent e) {
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(final ComponentEvent e) {
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(final ComponentEvent e) {
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(final ComponentEvent e) {
|
||||
hidePopup();
|
||||
}
|
||||
};
|
||||
window.addComponentListener(componentAdapter);
|
||||
Disposer.register(popupToolbar, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
window.removeComponentListener(componentAdapter);
|
||||
}
|
||||
@@ -1091,7 +1127,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
|
||||
abstract static class PopupToolbar extends ActionToolbarImpl implements AnActionListener, Disposable {
|
||||
private JComponent myParent;
|
||||
private final JComponent myParent;
|
||||
|
||||
public PopupToolbar(final String place,
|
||||
final ActionGroup actionGroup,
|
||||
@@ -1111,13 +1147,16 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
return parent != null ? parent : myParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myActionManager.removeAnActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformed(final AnAction action, final DataContext dataContext, AnActionEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(final AnAction action, final DataContext dataContext, AnActionEvent event) {
|
||||
if (!myVisibleActions.contains(action)) {
|
||||
onOtherActionPerformed();
|
||||
@@ -1126,19 +1165,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
protected abstract void onOtherActionPerformed();
|
||||
|
||||
@Override
|
||||
public void beforeEditorTyping(final char c, final DataContext dataContext) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setReservePlaceAutoPopupIcon(final boolean reserve) {
|
||||
myReservePlaceAutoPopupIcon = reserve;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondaryActionsTooltip(String secondaryActionsTooltip) {
|
||||
mySecondaryActions.getTemplatePresentation().setDescription(secondaryActionsTooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SwitchTarget> getTargets(boolean onlyVisible, boolean originalProvider) {
|
||||
ArrayList<SwitchTarget> result = new ArrayList<SwitchTarget>();
|
||||
|
||||
@@ -1160,19 +1203,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
myButton = button;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionCallback switchTo(boolean requestFocus) {
|
||||
myButton.click();
|
||||
return new ActionCallback.Done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return myButton.isVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelativeRectangle getRectangle() {
|
||||
return new RelativeRectangle(myButton.getParent(), myButton.getBounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
return myButton;
|
||||
}
|
||||
@@ -1183,14 +1230,17 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwitchTarget getCurrentTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCycleRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnAction> getActions(boolean originalProvider) {
|
||||
ArrayList<AnAction> result = new ArrayList<AnAction>();
|
||||
|
||||
|
||||
+1
-2
@@ -30,7 +30,6 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.FocusWatcher;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.PrevNextActionsDescriptor;
|
||||
import com.intellij.ui.SideBorder;
|
||||
import com.intellij.ui.TabbedPaneWrapper;
|
||||
@@ -226,7 +225,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
}
|
||||
|
||||
private void fireSelectedEditorChanged(final FileEditor oldSelectedEditor, final FileEditor newSelectedEditor){
|
||||
if (!myFileEditorManager.isInsideChange() && !Comparing.equal(oldSelectedEditor, newSelectedEditor)) {
|
||||
if ((!EventQueue.isDispatchThread() || !myFileEditorManager.isInsideChange()) && !Comparing.equal(oldSelectedEditor, newSelectedEditor)) {
|
||||
myFileEditorManager.notifyPublisher(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
+13
-1
@@ -796,7 +796,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
}
|
||||
|
||||
// Restore selected editor
|
||||
final FileEditorProvider selectedProvider = editorHistoryManager.getSelectedProvider(file);
|
||||
final FileEditorProvider selectedProvider = getSelectedFileEditorProvider(editorHistoryManager, file);
|
||||
if (selectedProvider != null) {
|
||||
final FileEditor[] _editors = newSelectedComposite.getEditors();
|
||||
final FileEditorProvider[] _providers = newSelectedComposite.getProviders();
|
||||
@@ -866,6 +866,18 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
return Pair.create(editors, providers);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FileEditorProvider getSelectedFileEditorProvider(EditorHistoryManager editorHistoryManager, VirtualFile file) {
|
||||
for (SelectedFileEditorProvider selectedEditorProvider : Extensions
|
||||
.getExtensions(SelectedFileEditorProvider.EP_SELECTED_FILE_EDITOR_PROVIDER)) {
|
||||
FileEditorProvider provider = selectedEditorProvider.getSelectedProvider(myProject, file);
|
||||
if (file != null) {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
return editorHistoryManager.getSelectedProvider(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionCallback notifyPublisher(final Runnable runnable) {
|
||||
final IdeFocusManager focusManager = IdeFocusManager.getInstance(myProject);
|
||||
|
||||
@@ -17,8 +17,10 @@ package com.intellij.openapi.keymap.ex;
|
||||
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
||||
import com.intellij.openapi.options.SchemesManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -40,4 +42,8 @@ public abstract class KeymapManagerEx extends KeymapManager {
|
||||
public abstract String getActionBinding(String actionId);
|
||||
|
||||
public abstract SchemesManager<Keymap, KeymapImpl> getSchemesManager();
|
||||
|
||||
public abstract void addWeakListener(@NotNull KeymapManagerListener listener);
|
||||
|
||||
public abstract void removeWeakListener(@NotNull KeymapManagerListener listenerToRemove);
|
||||
}
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.keymap.ex;
|
||||
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public final class WeakKeymapManagerListener implements KeymapManagerListener{
|
||||
private final KeymapManagerEx myKeymapManager;
|
||||
private final WeakReference<KeymapManagerListener> myRef;
|
||||
|
||||
public WeakKeymapManagerListener(KeymapManagerEx keymapManager,KeymapManagerListener delegate){
|
||||
myKeymapManager=keymapManager;
|
||||
myRef=new WeakReference<KeymapManagerListener>(delegate);
|
||||
}
|
||||
|
||||
public void activeKeymapChanged(Keymap keymap){
|
||||
KeymapManagerListener delegate= myRef.get();
|
||||
if(delegate!=null){
|
||||
delegate.activeKeymapChanged(keymap);
|
||||
}else{
|
||||
myKeymapManager.removeKeymapManagerListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
-25
@@ -44,11 +44,10 @@ import java.util.*;
|
||||
roamingType = RoamingType.PER_PLATFORM,
|
||||
storages = {
|
||||
@Storage(
|
||||
file = StoragePathMacros.APP_CONFIG + "/keymap.xml"
|
||||
file = StoragePathMacros.APP_CONFIG + "/keymap.xml"
|
||||
)}
|
||||
)
|
||||
public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStateComponent<Element>, ExportableApplicationComponent {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.keymap.KeymapManager");
|
||||
|
||||
private final List<KeymapManagerListener> myListeners = ContainerUtil.createEmptyCOWList();
|
||||
@@ -65,21 +64,24 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
|
||||
KeymapManagerImpl(DefaultKeymap defaultKeymap, SchemesManagerFactory factory) {
|
||||
mySchemesManager = factory.createSchemesManager(
|
||||
"$ROOT_CONFIG$/keymaps",
|
||||
new BaseSchemeProcessor<KeymapImpl>(){
|
||||
public KeymapImpl readScheme(final Document schemeContent) throws InvalidDataException, IOException, JDOMException {
|
||||
return readKeymap(schemeContent);
|
||||
}
|
||||
"$ROOT_CONFIG$/keymaps",
|
||||
new BaseSchemeProcessor<KeymapImpl>() {
|
||||
@Override
|
||||
public KeymapImpl readScheme(final Document schemeContent) throws InvalidDataException, IOException, JDOMException {
|
||||
return readKeymap(schemeContent);
|
||||
}
|
||||
|
||||
public Document writeScheme(final KeymapImpl scheme) throws WriteExternalException {
|
||||
return new Document(scheme.writeExternal());
|
||||
}
|
||||
@Override
|
||||
public Document writeScheme(final KeymapImpl scheme) throws WriteExternalException {
|
||||
return new Document(scheme.writeExternal());
|
||||
}
|
||||
|
||||
public boolean shouldBeSaved(final KeymapImpl scheme) {
|
||||
return scheme.canModify();
|
||||
}
|
||||
},
|
||||
RoamingType.PER_USER);
|
||||
@Override
|
||||
public boolean shouldBeSaved(final KeymapImpl scheme) {
|
||||
return scheme.canModify();
|
||||
}
|
||||
},
|
||||
RoamingType.PER_USER);
|
||||
|
||||
Keymap[] keymaps = defaultKeymap.getKeymaps();
|
||||
for (Keymap keymap : keymaps) {
|
||||
@@ -93,16 +95,19 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
ourKeymapManagerInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File[] getExportFiles() {
|
||||
return new File[]{new File(PathManager.getOptionsPath()+File.separatorChar+"keymap.xml"),getKeymapDirectory(true)};
|
||||
return new File[]{new File(PathManager.getOptionsPath() + File.separatorChar + "keymap.xml"), getKeymapDirectory(true)};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableName() {
|
||||
return KeyMapBundle.message("key.maps.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Keymap[] getAllKeymaps() {
|
||||
List<Keymap> answer = new ArrayList<Keymap>();
|
||||
for (Keymap keymap : mySchemesManager.getAllSchemes()) {
|
||||
@@ -118,32 +123,39 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
return keymaps.toArray(new Keymap[keymaps.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Keymap getKeymap(String name) {
|
||||
return mySchemesManager.findSchemeByName( name);
|
||||
return mySchemesManager.findSchemeByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Keymap getActiveKeymap() {
|
||||
return mySchemesManager.getCurrentScheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveKeymap(Keymap activeKeymap) {
|
||||
mySchemesManager.setCurrentSchemeName(activeKeymap == null ? null : activeKeymap.getName());
|
||||
fireActiveKeymapChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindShortcuts(String sourceActionId, String targetActionId) {
|
||||
myBoundShortcuts.put(targetActionId, sourceActionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getBoundActions() {
|
||||
return myBoundShortcuts.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionBinding(String actionId) {
|
||||
return myBoundShortcuts.get(actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemesManager<Keymap, KeymapImpl> getSchemesManager() {
|
||||
return mySchemesManager;
|
||||
}
|
||||
@@ -170,6 +182,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
return "keymap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element result = new Element("component");
|
||||
try {
|
||||
@@ -181,6 +194,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(final Element state) {
|
||||
try {
|
||||
readExternal(state);
|
||||
@@ -190,7 +204,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
}
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException{
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
Element child = element.getChild(ACTIVE_KEYMAP);
|
||||
if (child != null) {
|
||||
myActiveKeymapName = child.getAttributeValue(NAME_ATTRIBUTE);
|
||||
@@ -204,7 +218,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
}
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException{
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
if (mySchemesManager.getCurrentScheme() != null) {
|
||||
Element e = new Element(ACTIVE_KEYMAP);
|
||||
Keymap currentScheme = mySchemesManager.getCurrentScheme();
|
||||
@@ -215,11 +229,11 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
}
|
||||
}
|
||||
|
||||
private void load(){
|
||||
private void load() {
|
||||
mySchemesManager.loadSchemes();
|
||||
}
|
||||
|
||||
private KeymapImpl readKeymap(Document document) throws JDOMException,InvalidDataException, IOException{
|
||||
private KeymapImpl readKeymap(Document document) throws JDOMException, InvalidDataException, IOException {
|
||||
if (document == null) throw new InvalidDataException();
|
||||
Element root = document.getRootElement();
|
||||
if (root == null || !KEYMAP.equals(root.getName())) {
|
||||
@@ -251,20 +265,53 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
}
|
||||
}
|
||||
|
||||
public void addKeymapManagerListener(KeymapManagerListener listener) {
|
||||
@Override
|
||||
public void addKeymapManagerListener(@NotNull KeymapManagerListener listener) {
|
||||
pollQueue();
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeKeymapManagerListener(KeymapManagerListener listener) {
|
||||
private void pollQueue() {
|
||||
// assume it is safe to remove elements during iteration, as is the case with the COWAL
|
||||
for (KeymapManagerListener listener : myListeners) {
|
||||
if (listener instanceof WeakKeymapManagerListener && ((WeakKeymapManagerListener)listener).isDead()) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeKeymapManagerListener(@NotNull KeymapManagerListener listener) {
|
||||
pollQueue();
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWeakListener(@NotNull KeymapManagerListener listener) {
|
||||
addKeymapManagerListener(new WeakKeymapManagerListener(this, listener));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWeakListener(@NotNull KeymapManagerListener listenerToRemove) {
|
||||
// assume it is safe to remove elements during iteration, as is the case with the COWAL
|
||||
for (KeymapManagerListener listener : myListeners) {
|
||||
if (listener instanceof WeakKeymapManagerListener && ((WeakKeymapManagerListener)listener).isWrapped(listenerToRemove)) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "KeymapManager";
|
||||
}
|
||||
|
||||
public void initComponent() {}
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {}
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.keymap.impl;
|
||||
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
class WeakKeymapManagerListener implements KeymapManagerListener {
|
||||
private final KeymapManagerEx myKeymapManager;
|
||||
private final Reference<KeymapManagerListener> myRef;
|
||||
|
||||
WeakKeymapManagerListener(@NotNull KeymapManagerEx keymapManager, @NotNull KeymapManagerListener delegate) {
|
||||
myKeymapManager = keymapManager;
|
||||
myRef = new WeakReference<KeymapManagerListener>(delegate);
|
||||
}
|
||||
|
||||
public boolean isDead() {
|
||||
return myRef.get() == null;
|
||||
}
|
||||
|
||||
public boolean isWrapped(@NotNull KeymapManagerListener listener) {
|
||||
return myRef.get() == listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeKeymapChanged(Keymap keymap) {
|
||||
KeymapManagerListener delegate = myRef.get();
|
||||
if (delegate == null) {
|
||||
myKeymapManager.removeKeymapManagerListener(this);
|
||||
}
|
||||
else {
|
||||
delegate.activeKeymapChanged(keymap);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -219,11 +219,12 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
}
|
||||
|
||||
public void executeProcessUnderProgress(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException {
|
||||
ProgressIndicator oldIndicator = myThreadIndicator.get();
|
||||
ProgressIndicator oldIndicator = null;
|
||||
|
||||
if (progress != null) myThreadIndicator.set(progress);
|
||||
boolean set = progress != null && progress != (oldIndicator = myThreadIndicator.get());
|
||||
if (set) myThreadIndicator.set(progress);
|
||||
|
||||
final boolean modal = progress != null && progress.isModal();
|
||||
boolean modal = progress != null && progress.isModal();
|
||||
if (modal) myCurrentModalProgressCount.incrementAndGet();
|
||||
if (progress == null || progress instanceof ProgressWindow) myCurrentUnsafeProgressCount.incrementAndGet();
|
||||
|
||||
@@ -231,7 +232,9 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
|
||||
process.run();
|
||||
}
|
||||
finally {
|
||||
myThreadIndicator.set(oldIndicator);
|
||||
if (set) {
|
||||
myThreadIndicator.set(oldIndicator);
|
||||
}
|
||||
|
||||
if (modal) myCurrentModalProgressCount.decrementAndGet();
|
||||
if (progress == null || progress instanceof ProgressWindow) myCurrentUnsafeProgressCount.decrementAndGet();
|
||||
|
||||
@@ -215,13 +215,14 @@ class CacheUpdateRunner {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (myInnerIndicator.isCanceled()) return;
|
||||
|
||||
final FileContent fileContent = myQueue.take(myInnerIndicator);
|
||||
final FileContent fileContent = myQueue.take();
|
||||
if (fileContent == null) {
|
||||
myFinished.set(Boolean.TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
myQueue.waitForOtherContentReleaseToPreventOOM(myInnerIndicator, fileContent);
|
||||
final Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
myInnerIndicator.checkCanceled();
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -299,7 +300,6 @@ public class DumbServiceImpl extends DumbService {
|
||||
|
||||
public void run() {
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, IdeBundle.message("progress.indexing"), false) {
|
||||
private final BlockingQueue<Ref<CacheUpdateRunner>> myActionQueue = new LinkedBlockingQueue<Ref<CacheUpdateRunner>>();
|
||||
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
@@ -347,6 +347,10 @@ public class DumbServiceImpl extends DumbService {
|
||||
shutdownTracker.registerStopperThread(self);
|
||||
runAction(proxy, myAction);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
LOG.error(e);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
shutdownTracker.unregisterStopperThread(self);
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
@@ -354,80 +358,66 @@ public class DumbServiceImpl extends DumbService {
|
||||
}
|
||||
|
||||
private void runAction(ProgressIndicator indicator, CacheUpdateRunner updateRunner) {
|
||||
do {
|
||||
int count = 0;
|
||||
try {
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
count = updateRunner.queryNeededFiles(indicator);
|
||||
while (updateRunner != null) {
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
int count = updateRunner.queryNeededFiles(indicator);
|
||||
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updating"));
|
||||
if (count > 0) {
|
||||
updateRunner.processFiles(indicator, true);
|
||||
}
|
||||
updateRunner.updatingDone();
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updating"));
|
||||
if (count > 0) {
|
||||
updateRunner.processFiles(indicator, true);
|
||||
}
|
||||
finally {
|
||||
myProcessedItems += count;
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Scheduling checkNextUpdateFromQueue; Thread: " + Thread.currentThread().getName());
|
||||
}
|
||||
UIUtil.invokeLaterIfNeeded(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
checkNextUpdateFromQueue();
|
||||
}
|
||||
});
|
||||
updateRunner.updatingDone();
|
||||
myProcessedItems += count;
|
||||
|
||||
// try to obtain the next action or terminate if no actions left
|
||||
Ref<CacheUpdateRunner> ref = null;
|
||||
do {
|
||||
try {
|
||||
ref = myActionQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
updateRunner = ref != null? ref.get() : null;
|
||||
if (myProject.isDisposed()) {
|
||||
// just terminate the progress task
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (ref == null);
|
||||
}
|
||||
updateRunner = getNextUpdateRunner();
|
||||
}
|
||||
while (updateRunner != null);
|
||||
}
|
||||
|
||||
private void checkNextUpdateFromQueue() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Inside checkNextUpdateFromQueue, Thread: " + Thread.currentThread().getName());
|
||||
@Nullable
|
||||
private CacheUpdateRunner getNextUpdateRunner() {
|
||||
final BlockingQueue<Ref<CacheUpdateRunner>> actionQueue = new LinkedBlockingQueue<Ref<CacheUpdateRunner>>();
|
||||
UIUtil.invokeLaterIfNeeded(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
IndexUpdateRunnable nextRunnable = getNextUpdateFromQueue();
|
||||
try {
|
||||
actionQueue.offer(nextRunnable == null ? NULL_ACTION : new Ref<CacheUpdateRunner>(nextRunnable.myAction));
|
||||
}
|
||||
finally {
|
||||
if (nextRunnable == null) {
|
||||
updateFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// try to obtain the next action or terminate if no actions left
|
||||
while (!myProject.isDisposed()) {
|
||||
try {
|
||||
Ref<CacheUpdateRunner> ref = actionQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
if (ref != null) {
|
||||
return ref.get();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
IndexUpdateRunnable nextUpdateRunnable = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IndexUpdateRunnable getNextUpdateFromQueue() {
|
||||
try {
|
||||
nextUpdateRunnable = myUpdatesQueue.isEmpty()? null : myUpdatesQueue.pullFirst();
|
||||
if (nextUpdateRunnable == null) {
|
||||
// really terminate the task
|
||||
myActionQueue.offer(NULL_ACTION);
|
||||
}
|
||||
else {
|
||||
//run next dumb action
|
||||
// run next action under already existing progress indicator
|
||||
myActionQueue.offer(new Ref<CacheUpdateRunner>(nextUpdateRunnable.myAction));
|
||||
}
|
||||
return myUpdatesQueue.isEmpty()? null : myUpdatesQueue.pullFirst();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myActionQueue.offer(NULL_ACTION);
|
||||
LOG.info(e);
|
||||
}
|
||||
finally {
|
||||
if (nextUpdateRunnable == null) {
|
||||
updateFinished();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -139,47 +139,36 @@ public class FileContentQueue {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FileContent take(@NotNull ProgressIndicator indicator) {
|
||||
FileContent content = doTake();
|
||||
if (content != null) {
|
||||
final long length = content.getLength();
|
||||
while (true) {
|
||||
void waitForOtherContentReleaseToPreventOOM(ProgressIndicator indicator, FileContent content) {
|
||||
final long length = content.getLength();
|
||||
while (true) {
|
||||
indicator.checkCanceled();
|
||||
synchronized (this) {
|
||||
boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = true;
|
||||
}
|
||||
try {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
pushback(content);
|
||||
throw e;
|
||||
}
|
||||
synchronized (this) {
|
||||
boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = true;
|
||||
}
|
||||
try {
|
||||
if (myLargeSizeRequested && !requestingLargeSize ||
|
||||
myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length))
|
||||
wait(300L);
|
||||
else {
|
||||
myTakenSize += length;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = false;
|
||||
}
|
||||
return content;
|
||||
if (myLargeSizeRequested && !requestingLargeSize ||
|
||||
myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length))
|
||||
wait(300L);
|
||||
else {
|
||||
myTakenSize += length;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (InterruptedException ignore) {
|
||||
}
|
||||
catch (InterruptedException ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FileContent doTake() {
|
||||
FileContent take() {
|
||||
FileContent result;
|
||||
synchronized (this) {
|
||||
result = myPushbackBuffer.poll();
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
@@ -79,7 +78,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
* Catches all event from tool window and modifies decorator's appearance.
|
||||
*/
|
||||
private final ToolWindowHandler myToolWindowHandler;
|
||||
private final WeakKeymapManagerListener myWeakKeymapManagerListener;
|
||||
private final MyKeymapManagerListener myWeakKeymapManagerListener;
|
||||
@NonNls private static final String HIDE_ACTIVE_WINDOW_ACTION_ID = "HideActiveWindow";
|
||||
@NonNls private static final String TOGGLE_PINNED_MODE_ACTION_ID = "TogglePinnedMode";
|
||||
@NonNls private static final String TOGGLE_DOCK_MODE_ACTION_ID = "ToggleDockMode";
|
||||
@@ -115,6 +114,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
return isFocused();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hideToolWindow() {
|
||||
fireHidden();
|
||||
}
|
||||
@@ -132,8 +132,8 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
|
||||
MyKeymapManagerListener keymapManagerListener = new MyKeymapManagerListener();
|
||||
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
|
||||
myWeakKeymapManagerListener = new WeakKeymapManagerListener(keymapManager, keymapManagerListener);
|
||||
keymapManager.addKeymapManagerListener(myWeakKeymapManagerListener);
|
||||
myWeakKeymapManagerListener = keymapManagerListener;
|
||||
keymapManager.addWeakListener(keymapManagerListener);
|
||||
|
||||
init();
|
||||
|
||||
@@ -204,6 +204,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myToolWindow.getContentUI().setType(myInfo.getContentUiType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calcData(DataKey key, DataSink sink) {
|
||||
if (PlatformDataKeys.TOOL_WINDOW.equals(key)) {
|
||||
sink.put(PlatformDataKeys.TOOL_WINDOW, myToolWindow);
|
||||
@@ -221,7 +222,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
final void dispose() {
|
||||
removeAll();
|
||||
myToolWindow.removePropertyChangeListener(myToolWindowHandler);
|
||||
KeymapManagerEx.getInstanceEx().removeKeymapManagerListener(myWeakKeymapManagerListener);
|
||||
KeymapManagerEx.getInstanceEx().removeWeakListener(myWeakKeymapManagerListener);
|
||||
|
||||
Disposer.dispose(myHeader);
|
||||
myHeader = null;
|
||||
@@ -322,6 +323,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
|
||||
// Add listeners
|
||||
registerKeyboardAction(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
ToolWindowManager.getInstance(myProject).activateEditorComponent();
|
||||
}
|
||||
@@ -340,6 +342,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myWindow = window;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
doPaintBorder(c, g, x, y, width, height);
|
||||
@@ -373,6 +376,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myWindow.getAnchor() == ToolWindowAnchor.TOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(final Component c) {
|
||||
UISettings settings = UISettings.getInstance();
|
||||
|
||||
@@ -434,6 +438,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
@@ -542,6 +547,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
return myHeader.getPreferredSize().height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void processComponentEvent(final ComponentEvent e) {
|
||||
super.processComponentEvent(e);
|
||||
if (ComponentEvent.COMPONENT_RESIZED == e.getID()) {
|
||||
@@ -581,6 +587,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myAnchor = anchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(final AnActionEvent e) {
|
||||
fireAnchorChanged(myAnchor);
|
||||
}
|
||||
@@ -591,10 +598,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
copyFrom(ActionManager.getInstance().getAction(TOGGLE_PINNED_MODE_ACTION_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(final AnActionEvent event) {
|
||||
return !myInfo.isAutoHide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(final AnActionEvent event, final boolean flag) {
|
||||
fireAutoHideChanged(!myInfo.isAutoHide());
|
||||
}
|
||||
@@ -605,10 +614,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
copyFrom(ActionManager.getInstance().getAction(TOGGLE_DOCK_MODE_ACTION_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(final AnActionEvent event) {
|
||||
return myInfo.isDocked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(final AnActionEvent event, final boolean flag) {
|
||||
if (myInfo.isDocked()) {
|
||||
fireTypeChanged(ToolWindowType.SLIDING);
|
||||
@@ -624,10 +635,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
copyFrom(ActionManager.getInstance().getAction(TOGGLE_FLOATING_MODE_ACTION_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(final AnActionEvent event) {
|
||||
return myInfo.isFloating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(final AnActionEvent event, final boolean flag) {
|
||||
if (myInfo.isFloating()) {
|
||||
fireTypeChanged(myInfo.getInternalType());
|
||||
@@ -643,10 +656,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
copyFrom(ActionManager.getInstance().getAction(TOGGLE_SIDE_MODE_ACTION_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(final AnActionEvent event) {
|
||||
return myInfo.isSplit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(final AnActionEvent event, final boolean flag) {
|
||||
fireSideStatusChanged(flag);
|
||||
}
|
||||
@@ -665,10 +680,12 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
getTemplatePresentation().setText(UIBundle.message("tool.window.hide.action.name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(final AnActionEvent e) {
|
||||
fireHidden();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void update(final AnActionEvent event) {
|
||||
final Presentation presentation = event.getPresentation();
|
||||
presentation.setEnabled(myInfo.isVisible());
|
||||
@@ -702,6 +719,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
setBorder(new DividerBorder());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void processMouseMotionEvent(final MouseEvent e) {
|
||||
super.processMouseMotionEvent(e);
|
||||
if (MouseEvent.MOUSE_DRAGGED == e.getID()) {
|
||||
@@ -745,6 +763,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void processMouseEvent(final MouseEvent e) {
|
||||
super.processMouseEvent(e);
|
||||
final ToolWindowAnchor anchor = myInfo.getAnchor();
|
||||
@@ -776,6 +795,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
|
||||
private final class DividerBorder implements Border {
|
||||
@Override
|
||||
public final void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
|
||||
final ToolWindowAnchor anchor = myInfo.getAnchor();
|
||||
final boolean isVertical = anchor == ToolWindowAnchor.TOP || anchor == ToolWindowAnchor.BOTTOM;
|
||||
@@ -809,6 +829,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Insets getBorderInsets(final Component c) {
|
||||
if (c instanceof MyDivider) {
|
||||
return new Insets(1, 1, 1, 1);
|
||||
@@ -816,6 +837,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isBorderOpaque() {
|
||||
return true;
|
||||
}
|
||||
@@ -826,6 +848,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
* Updates tooltips.
|
||||
*/
|
||||
private final class MyKeymapManagerListener implements KeymapManagerListener {
|
||||
@Override
|
||||
public final void activeKeymapChanged(final Keymap keymap) {
|
||||
if (myHeader != null) {
|
||||
myHeader.updateTooltips();
|
||||
@@ -837,6 +860,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
* Synchronizes decorator with IdeToolWindow changes.
|
||||
*/
|
||||
private final class ToolWindowHandler implements PropertyChangeListener {
|
||||
@Override
|
||||
public final void propertyChange(final PropertyChangeEvent e) {
|
||||
final String name = e.getPropertyName();
|
||||
if (ToolWindowEx.PROP_TITLE.equals(name)) {
|
||||
@@ -848,6 +872,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(@NotNull Map<String, String> info) {
|
||||
info.put("toolWindowTitle", myToolWindow.getTitle());
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
@@ -44,7 +43,7 @@ import java.util.List;
|
||||
final class Stripe extends JPanel{
|
||||
private final int myAnchor;
|
||||
private final ArrayList<StripeButton> myButtons = new ArrayList<StripeButton>();
|
||||
private final WeakKeymapManagerListener myWeakKeymapManagerListener;
|
||||
private final MyKeymapManagerListener myWeakKeymapManagerListener;
|
||||
private final MyUISettingsListener myUISettingsListener;
|
||||
|
||||
private Dimension myPrefSize;
|
||||
@@ -63,7 +62,7 @@ final class Stripe extends JPanel{
|
||||
setOpaque(true);
|
||||
myManager = manager;
|
||||
myAnchor = anchor;
|
||||
myWeakKeymapManagerListener=new WeakKeymapManagerListener(KeymapManagerEx.getInstanceEx(), new MyKeymapManagerListener());
|
||||
myWeakKeymapManagerListener=new MyKeymapManagerListener();
|
||||
myUISettingsListener=new MyUISettingsListener();
|
||||
setBorder(new AdaptiveBorder());
|
||||
}
|
||||
@@ -130,19 +129,21 @@ final class Stripe extends JPanel{
|
||||
/**
|
||||
* Invoked when enclosed frame is being shown.
|
||||
*/
|
||||
@Override
|
||||
public void addNotify(){
|
||||
super.addNotify();
|
||||
updateText();
|
||||
updateState();
|
||||
KeymapManagerEx.getInstanceEx().addKeymapManagerListener(myWeakKeymapManagerListener);
|
||||
KeymapManagerEx.getInstanceEx().addWeakListener(myWeakKeymapManagerListener);
|
||||
UISettings.getInstance().addUISettingsListener(myUISettingsListener,myDisposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when enclosed frame is being disposed.
|
||||
*/
|
||||
@Override
|
||||
public void removeNotify(){
|
||||
KeymapManagerEx.getInstanceEx().removeKeymapManagerListener(myWeakKeymapManagerListener);
|
||||
KeymapManagerEx.getInstanceEx().removeWeakListener(myWeakKeymapManagerListener);
|
||||
Disposer.dispose(myDisposable);
|
||||
super.removeNotify();
|
||||
}
|
||||
@@ -166,11 +167,13 @@ final class Stripe extends JPanel{
|
||||
return Collections.unmodifiableList(myButtons);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
myPrefSize = null;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
if (!myFinishingDrop) {
|
||||
myLastLayoutData = recomputeBounds(true, getSize());
|
||||
@@ -432,6 +435,7 @@ final class Stripe extends JPanel{
|
||||
return myAnchor == SwingConstants.TOP || myAnchor == SwingConstants.BOTTOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (myPrefSize == null) {
|
||||
myPrefSize = recomputeBounds(false, null).size;
|
||||
@@ -473,6 +477,7 @@ final class Stripe extends JPanel{
|
||||
myManager.setSideToolAndAnchor(info.getId(), ToolWindowAnchor.get(myAnchor), myLastLayoutData.dragInsertPosition, myLastLayoutData.dragToSide);
|
||||
|
||||
myManager.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
resetDrop();
|
||||
}
|
||||
@@ -515,12 +520,14 @@ final class Stripe extends JPanel{
|
||||
}
|
||||
|
||||
private final class MyKeymapManagerListener implements KeymapManagerListener {
|
||||
@Override
|
||||
public void activeKeymapChanged(final Keymap keymap){
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
private final class MyUISettingsListener implements UISettingsListener{
|
||||
@Override
|
||||
public void uiSettingsChanged(final UISettings source){
|
||||
updateText();
|
||||
updateState();
|
||||
@@ -572,6 +579,7 @@ final class Stripe extends JPanel{
|
||||
return myCachedBg;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
super.paintComponent(g);
|
||||
if (!myFinishingDrop && isDroppingButton() && myDragButton.getParent() != this) {
|
||||
|
||||
@@ -81,6 +81,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
* excepting firing of the MNEMONIC_CHANGED_PROPERTY event. After that mnemonic
|
||||
* doesn't work via standard Swing rules (processing of Alt keystrokes).
|
||||
*/
|
||||
@Override
|
||||
public void setMnemonic(final int mnemonic) {
|
||||
throw new UnsupportedOperationException("use setMnemonic2(int)");
|
||||
}
|
||||
@@ -119,9 +120,10 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
setRolloverEnabled(true);
|
||||
setOpaque(false);
|
||||
|
||||
enableEvents(MouseEvent.MOUSE_EVENT_MASK);
|
||||
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
|
||||
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseDragged(final MouseEvent e) {
|
||||
processDrag(e);
|
||||
}
|
||||
@@ -155,12 +157,12 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
if (!component.isVisible()) continue;
|
||||
Rectangle r = component.getBounds();
|
||||
if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
|
||||
if (first && (max > r.y) || (!first && max < r.y)) {
|
||||
if (first && max > r.y || !first && max < r.y) {
|
||||
max = r.y;
|
||||
c = component;
|
||||
}
|
||||
} else {
|
||||
if (first && (max > r.x) || (!first && max < r.x)) {
|
||||
if (first && max > r.x || !first && max < r.x) {
|
||||
max = r.x;
|
||||
c = component;
|
||||
}
|
||||
@@ -249,6 +251,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
return root.getLayeredPane();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processMouseEvent(final MouseEvent e) {
|
||||
if (e.isPopupTrigger() && e.getComponent().isShowing()) {
|
||||
super.processMouseEvent(e);
|
||||
@@ -276,6 +279,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
super.processMouseEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
if (myPressedWhenSelected) {
|
||||
myDecorator.fireHidden();
|
||||
@@ -301,6 +305,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
popupMenu.getComponent().show(component, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
setUI(StripeButtonUI.createUI(this));
|
||||
Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
|
||||
@@ -322,7 +327,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
if (UISettings.getInstance().SHOW_TOOL_WINDOW_NUMBERS) {
|
||||
final int mnemonic = ActivateToolWindowAction.getMnemonicForToolWindow(toolWindowId);
|
||||
if (mnemonic != -1) {
|
||||
text = ((char)mnemonic) + ": " + text;
|
||||
text = (char)mnemonic + ": " + text;
|
||||
setMnemonic2(mnemonic);
|
||||
}
|
||||
else {
|
||||
@@ -345,12 +350,14 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
}
|
||||
|
||||
private final class MyPopupHandler extends PopupHandler {
|
||||
@Override
|
||||
public void invokePopup(final Component component, final int x, final int y) {
|
||||
showPopup(component, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private final class MyPropertyChangeListener implements PropertyChangeListener {
|
||||
@Override
|
||||
public void propertyChange(final PropertyChangeEvent e) {
|
||||
final String name = e.getPropertyName();
|
||||
if (ToolWindowEx.PROP_AVAILABLE.equals(name)) {
|
||||
|
||||
@@ -246,7 +246,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final String text) {
|
||||
public void setText(@NotNull final String text) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<extensionPoint name="fileEditorProvider"
|
||||
interface="com.intellij.openapi.fileEditor.FileEditorProvider"/>
|
||||
|
||||
<extensionPoint name="selectedFileEditorProvider"
|
||||
interface="com.intellij.openapi.fileEditor.SelectedFileEditorProvider"/>
|
||||
|
||||
<extensionPoint name="fileTypeFactory"
|
||||
interface="com.intellij.openapi.fileTypes.FileTypeFactory"/>
|
||||
|
||||
@@ -139,6 +142,7 @@
|
||||
<extensionPoint name="projectAttachProcessor" interface="com.intellij.projectImport.ProjectAttachProcessor"/>
|
||||
|
||||
<extensionPoint name="pathMacroFilter" interface="com.intellij.openapi.application.PathMacroFilter"/>
|
||||
<extensionPoint name="pathMacroExpendableProtocol" beanClass="com.intellij.application.options.PathMacroExpendableProtocolBean"/>
|
||||
|
||||
<extensionPoint name="serverPipelineConsumer" interface="com.intellij.util.Consumer"/>
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.application.options;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
|
||||
public class PathMacroExpendableProtocolBean {
|
||||
public static ExtensionPointName<PathMacroExpendableProtocolBean> EP_NAME = ExtensionPointName.create("com.intellij.pathMacroExpendableProtocol");
|
||||
|
||||
@Attribute("protocol")
|
||||
public String protocol;
|
||||
}
|
||||
+11
-1
@@ -17,6 +17,7 @@ package com.intellij.application.options;
|
||||
|
||||
import com.intellij.openapi.components.PathMacroMap;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -37,7 +38,16 @@ public class ReplacePathToMacroMap extends PathMacroMap {
|
||||
private List<String> myPathsIndex = null;
|
||||
private final Map<String, String> myMacroMap = ContainerUtilRt.newLinkedHashMap();
|
||||
|
||||
@NonNls private static final String[] PROTOCOLS = new String[]{"file", "jar"};
|
||||
@NonNls private static final String[] PROTOCOLS;
|
||||
static {
|
||||
List<String> protocols = new ArrayList<String>();
|
||||
protocols.add("file");
|
||||
protocols.add("jar");
|
||||
for (PathMacroExpendableProtocolBean bean : PathMacroExpendableProtocolBean.EP_NAME.getExtensions()) {
|
||||
protocols.add(bean.protocol);
|
||||
}
|
||||
PROTOCOLS = ArrayUtil.toStringArray(protocols);
|
||||
}
|
||||
|
||||
public void addMacroReplacement(String path, String macroName) {
|
||||
addReplacement(quotePath(path), "$" + macroName + "$", true);
|
||||
|
||||
@@ -21,13 +21,12 @@ import com.intellij.util.containers.FList;
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.text.Matcher;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static com.intellij.psi.codeStyle.NameUtil.MatchingCaseSensitivity.*;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -52,7 +51,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
myHasHumps = false;
|
||||
}
|
||||
|
||||
private static FList<TextRange> prependRange(FList<TextRange> ranges, int from, int length) {
|
||||
private static FList<TextRange> prependRange(@NotNull FList<TextRange> ranges, int from, int length) {
|
||||
TextRange head = ranges.getHead();
|
||||
if (head != null && head.getStartOffset() == from + length) {
|
||||
return ranges.getTail().prepend(new TextRange(from, head.getEndOffset()));
|
||||
@@ -60,7 +59,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
return ranges.prepend(TextRange.from(from, length));
|
||||
}
|
||||
|
||||
public int matchingDegree(String name) {
|
||||
public int matchingDegree(@NotNull String name) {
|
||||
Iterable<TextRange> iterable = matchingFragments(name);
|
||||
if (iterable == null) return Integer.MIN_VALUE;
|
||||
|
||||
@@ -110,7 +109,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
return -fragmentCount + matchingCase * 20 + commonStart * 30 - startIndex + (prefixMatching ? 2 : middleWordStart ? 1 : 0) * 1000 - integral;
|
||||
}
|
||||
|
||||
public boolean isStartMatch(String name) {
|
||||
public boolean isStartMatch(@NotNull String name) {
|
||||
Iterable<TextRange> fragments = matchingFragments(name);
|
||||
if (fragments != null) {
|
||||
Iterator<TextRange> iterator = fragments.iterator();
|
||||
@@ -121,7 +120,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isStartMatch(String name, int startIndex) {
|
||||
private static boolean isStartMatch(@NotNull String name, int startIndex) {
|
||||
for (int i = 0; i < startIndex; i++) {
|
||||
if (!NameUtil.isWordSeparator(name.charAt(i))) {
|
||||
return false;
|
||||
@@ -131,17 +130,17 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(String name) {
|
||||
public boolean matches(@NotNull String name) {
|
||||
return matchingFragments(name) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Iterable<TextRange> matchingFragments(String name) {
|
||||
public Iterable<TextRange> matchingFragments(@NotNull String name) {
|
||||
return matchWildcards(name, 0, 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FList<TextRange> matchWildcards(String name, int patternIndex, int nameIndex) {
|
||||
private FList<TextRange> matchWildcards(@NotNull String name, int patternIndex, int nameIndex) {
|
||||
if (nameIndex < 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -172,7 +171,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FList<TextRange> matchSkippingWords(String name, int patternIndex, int nameIndex, boolean allowSpecialChars) {
|
||||
private FList<TextRange> matchSkippingWords(@NotNull String name, int patternIndex, int nameIndex, boolean allowSpecialChars) {
|
||||
boolean star = isPatternChar(patternIndex - 1, '*');
|
||||
char p = myPattern[patternIndex];
|
||||
while (true) {
|
||||
@@ -191,7 +190,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FList<TextRange> matchFragment(String name, int patternIndex, int nameIndex) {
|
||||
private FList<TextRange> matchFragment(@NotNull String name, int patternIndex, int nameIndex) {
|
||||
if (!isFirstCharMatching(name, nameIndex, myPattern[patternIndex])) {
|
||||
return null;
|
||||
}
|
||||
@@ -200,7 +199,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
int i = 1;
|
||||
while (nameIndex + i < name.length() &&
|
||||
patternIndex + i < myPattern.length &&
|
||||
StringUtil.charsEqual(myPattern[patternIndex + i], name.charAt(nameIndex + i), myOptions != ALL)) {
|
||||
StringUtil.charsEqual(myPattern[patternIndex + i], name.charAt(nameIndex + i), myOptions != NameUtil.MatchingCaseSensitivity.ALL)) {
|
||||
if (Character.isUpperCase(myPattern[patternIndex + i])) {
|
||||
if (i < minFragment) {
|
||||
return null;
|
||||
@@ -231,20 +230,20 @@ public class MinusculeMatcher implements Matcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFirstCharMatching(String name, int nameIndex, char p) {
|
||||
private boolean isFirstCharMatching(@NotNull String name, int nameIndex, char p) {
|
||||
return nameIndex < name.length() && StringUtil.charsEqual(p, name.charAt(nameIndex),
|
||||
myOptions == FIRST_LETTER && nameIndex > 0 || myOptions == NONE);
|
||||
myOptions == NameUtil.MatchingCaseSensitivity.FIRST_LETTER && nameIndex > 0 ||
|
||||
myOptions == NameUtil.MatchingCaseSensitivity.NONE);
|
||||
}
|
||||
|
||||
private boolean isWildcard(int patternIndex) {
|
||||
return isPatternChar(patternIndex, ' ') || isPatternChar(patternIndex, '*');
|
||||
}
|
||||
private boolean isPatternChar(int patternIndex, char c) {
|
||||
if (patternIndex < 0 || patternIndex >= myPattern.length) return false;
|
||||
return myPattern[patternIndex] == c;
|
||||
return patternIndex >= 0 && patternIndex < myPattern.length && myPattern[patternIndex] == c;
|
||||
}
|
||||
|
||||
private int indexOfWordStart(String name, int patternIndex, int startFrom) {
|
||||
private int indexOfWordStart(@NotNull String name, int patternIndex, int startFrom) {
|
||||
char p = myPattern[patternIndex];
|
||||
if (p == '.' || NameUtil.isWordSeparator(p)) {
|
||||
return StringUtil.indexOfIgnoreCase(name, p, startFrom + 1);
|
||||
@@ -265,6 +264,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MinusculeMatcher{" +
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ConcurrencyUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NotNull final String threadFactoryName, final int threadPriority) {
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls @NotNull final String threadFactoryName, final int threadPriority) {
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
|
||||
public Thread newThread(final Runnable r) {
|
||||
final Thread thread = new Thread(r, threadFactoryName);
|
||||
|
||||
@@ -46,6 +46,7 @@ abstract class Timed<T> implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
final Object t = myT;
|
||||
myT = null;
|
||||
@@ -77,6 +78,7 @@ abstract class Timed<T> implements Disposable {
|
||||
static {
|
||||
ScheduledExecutorService service = ConcurrencyUtil.newSingleScheduledThreadExecutor("timed reference disposer", Thread.MIN_PRIORITY + 1);
|
||||
service.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
disposeTimed();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -239,6 +240,11 @@ public class MultiMap<K, V> implements Serializable {
|
||||
protected Collection<V> createCollection() {
|
||||
return new SmartList<V>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<K, Collection<V>> createMap() {
|
||||
return new THashMap<K, Collection<V>>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.intellij.util.text;
|
||||
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@SuppressWarnings("ClassNameSameAsAncestorName")
|
||||
public interface Matcher extends NameUtil.Matcher {
|
||||
boolean matches(String name);
|
||||
boolean matches(@NotNull String name);
|
||||
}
|
||||
|
||||
@@ -415,9 +415,9 @@ public class UIUtil {
|
||||
int defSize = getLabelFont().getSize();
|
||||
switch (size) {
|
||||
case SMALL:
|
||||
return Math.max(defSize - 2f, 10f);
|
||||
return Math.max(defSize - 2f, 11f);
|
||||
case MINI:
|
||||
return Math.max(defSize - 4f, 8f);
|
||||
return Math.max(defSize - 4f, 9f);
|
||||
default:
|
||||
return defSize;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
<fileEditorProvider implementation="com.intellij.android.designer.AndroidDesignerEditorProvider"/>
|
||||
|
||||
<selectedFileEditorProvider implementation="com.intellij.android.designer.AndroidSelectedFileEditorProvider"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.android.designer.profile.ProfileList"
|
||||
serviceImplementation="com.intellij.android.designer.profile.ProfileList"/>
|
||||
|
||||
@@ -20,6 +22,12 @@
|
||||
serviceImplementation="com.intellij.android.designer.model.ViewsMetaManager"/>
|
||||
</extensions>
|
||||
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.android.designer.AndroidSelectedFileEditorProvider$MyEditorListener</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.android">
|
||||
<refactoringContextProvider implementation="com.intellij.android.designer.AndroidDesignerRefactoringContextProvider"/>
|
||||
</extensions>
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.android.designer;
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class AndroidSelectedFileEditorProvider implements SelectedFileEditorProvider {
|
||||
private static final String KEY = "AndroidLayoutSelectedEditor";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FileEditorProvider getSelectedProvider(Project project, VirtualFile openedFile) {
|
||||
if (!AndroidDesignerEditorProvider.acceptLayout(project, openedFile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String editorTypeId = PropertiesComponent.getInstance(project).getValue(KEY);
|
||||
if (editorTypeId != null) {
|
||||
return FileEditorProviderManager.getInstance().getProvider(editorTypeId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class MyEditorListener implements ProjectComponent {
|
||||
private final Project myProject;
|
||||
|
||||
public MyEditorListener(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() {
|
||||
public void run() {
|
||||
myProject.getMessageBus().connect(myProject)
|
||||
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
|
||||
@Override
|
||||
public void fileOpened(FileEditorManager source, VirtualFile file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileClosed(FileEditorManager source, VirtualFile file) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(FileEditorManagerEvent event) {
|
||||
VirtualFile file = event.getNewFile();
|
||||
if (file != null && AndroidDesignerEditorProvider.acceptLayout(myProject, file)) {
|
||||
FileEditorProvider provider = EditorHistoryManager.getInstance(myProject).getSelectedProvider(file);
|
||||
if (provider != null) {
|
||||
PropertiesComponent.getInstance(myProject).setValue(KEY, provider.getEditorTypeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "AndroidLayoutSelectedEditorListener";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,7 +306,8 @@ public final class AndroidApt {
|
||||
}
|
||||
else {
|
||||
tempDir = FileUtil.createTempDirectory("android_combined_assets", "tmp");
|
||||
for (String assetDir : nonEmptyAssetDirs) {
|
||||
for (int i = nonEmptyAssetDirs.length - 1; i >= 0; i--) {
|
||||
final String assetDir = nonEmptyAssetDirs[i];
|
||||
FileUtil.copyDir(new File(assetDir), tempDir, assetsFilter);
|
||||
}
|
||||
args.add("-A");
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.android.builder.AndroidProjectBuildTarget;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidSdkProperties;
|
||||
import org.jetbrains.jps.builders.BuildOutputConsumer;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
@@ -68,8 +69,10 @@ public class AndroidDexBuilder extends TargetBuilder<BuildRootDescriptor,Android
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(@NotNull AndroidProjectBuildTarget target, @NotNull CompileContext context,
|
||||
DirtyFilesHolder<BuildRootDescriptor, AndroidProjectBuildTarget> holder) throws ProjectBuildException {
|
||||
public void build(@NotNull AndroidProjectBuildTarget target,
|
||||
@NotNull DirtyFilesHolder<BuildRootDescriptor, AndroidProjectBuildTarget> holder,
|
||||
@NotNull BuildOutputConsumer outputConsumer,
|
||||
@NotNull CompileContext context) throws ProjectBuildException {
|
||||
if (target.getKind() != AndroidProjectBuildTarget.AndroidBuilderKind.DEX && AndroidJpsUtil.isLightBuild(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+25
-15
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.android.builder.AndroidProjectBuildTarget;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
|
||||
import org.jetbrains.jps.builders.BuildOutputConsumer;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
@@ -60,8 +61,10 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(@NotNull AndroidProjectBuildTarget target, @NotNull CompileContext context,
|
||||
DirtyFilesHolder<BuildRootDescriptor, AndroidProjectBuildTarget> holder) throws ProjectBuildException {
|
||||
public void build(@NotNull AndroidProjectBuildTarget target,
|
||||
@NotNull DirtyFilesHolder<BuildRootDescriptor, AndroidProjectBuildTarget> holder,
|
||||
@NotNull BuildOutputConsumer outputConsumer,
|
||||
@NotNull CompileContext context) throws ProjectBuildException {
|
||||
if (target.getKind() != AndroidProjectBuildTarget.AndroidBuilderKind.PACKAGING || AndroidJpsUtil.isLightBuild(context)) {
|
||||
return;
|
||||
}
|
||||
@@ -249,10 +252,12 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
|
||||
boolean updateState = true;
|
||||
|
||||
// todo: recompile if PACK_ASSETS_FROM_LIBRARIES was changed
|
||||
|
||||
if (!extension.isLibrary() &&
|
||||
!(context.isMake() &&
|
||||
checkUpToDate(module, resourcesStates, resourcesStorage) &&
|
||||
checkUpToDate(module, assetsStates, assetsStorage) &&
|
||||
checkUpToDate(module, resourcesStates, resourcesStorage, true) &&
|
||||
checkUpToDate(module, assetsStates, assetsStorage, extension.isPackAssetsFromLibraries()) &&
|
||||
manifestFile.lastModified() == manifestStorage.getStamp(manifestFile, new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)))) {
|
||||
|
||||
updateState = packageResources(extension, manifestFile, context);
|
||||
@@ -465,20 +470,23 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
|
||||
private static boolean checkUpToDate(@NotNull JpsModule module,
|
||||
@NotNull Map<JpsModule, AndroidFileSetState> module2state,
|
||||
@NotNull AndroidFileSetStorage storage) throws IOException {
|
||||
@NotNull AndroidFileSetStorage storage,
|
||||
boolean withDependencies) throws IOException {
|
||||
final AndroidFileSetState moduleState = module2state.get(module);
|
||||
final AndroidFileSetState savedState = storage.getState(module.getName());
|
||||
if (savedState == null || !savedState.equalsTo(moduleState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (JpsAndroidModuleExtension libExtension : AndroidJpsUtil.getAllAndroidDependencies(module, true)) {
|
||||
final JpsModule libModule = libExtension.getModule();
|
||||
final AndroidFileSetState currentLibState = module2state.get(libModule);
|
||||
final AndroidFileSetState savedLibState = storage.getState(libModule.getName());
|
||||
if (withDependencies) {
|
||||
for (JpsAndroidModuleExtension libExtension : AndroidJpsUtil.getAllAndroidDependencies(module, true)) {
|
||||
final JpsModule libModule = libExtension.getModule();
|
||||
final AndroidFileSetState currentLibState = module2state.get(libModule);
|
||||
final AndroidFileSetState savedLibState = storage.getState(libModule.getName());
|
||||
|
||||
if (savedLibState == null || !savedLibState.equalsTo(currentLibState)) {
|
||||
return false;
|
||||
if (savedLibState == null || !savedLibState.equalsTo(currentLibState)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -557,11 +565,13 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
result.add(assetsDir.getPath());
|
||||
}
|
||||
|
||||
for (JpsAndroidModuleExtension depExtension : AndroidJpsUtil.getAllAndroidDependencies(extension.getModule(), true)) {
|
||||
final File depAssetsDir = depExtension.getAssetsDir();
|
||||
if (extension.isPackAssetsFromLibraries()) {
|
||||
for (JpsAndroidModuleExtension depExtension : AndroidJpsUtil.getAllAndroidDependencies(extension.getModule(), true)) {
|
||||
final File depAssetsDir = depExtension.getAssetsDir();
|
||||
|
||||
if (depAssetsDir != null) {
|
||||
result.add(depAssetsDir.getPath());
|
||||
if (depAssetsDir != null) {
|
||||
result.add(depAssetsDir.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -44,6 +44,8 @@ public interface JpsAndroidModuleExtension extends JpsElement {
|
||||
|
||||
boolean isPackTestCode();
|
||||
|
||||
boolean isPackAssetsFromLibraries();
|
||||
|
||||
boolean isRunProcessResourcesMavenTask();
|
||||
|
||||
boolean isRunProguard();
|
||||
|
||||
+5
@@ -177,6 +177,11 @@ public class JpsAndroidModuleExtensionImpl extends JpsElementBase<JpsAndroidModu
|
||||
return myProperties.PACK_TEST_CODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackAssetsFromLibraries() {
|
||||
return myProperties.PACK_ASSETS_FROM_LIBRARIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunProcessResourcesMavenTask() {
|
||||
return myProperties.RUN_PROCESS_RESOURCES_MAVEN_TASK;
|
||||
|
||||
+2
@@ -54,6 +54,8 @@ public class JpsAndroidModuleProperties {
|
||||
|
||||
public boolean PACK_TEST_CODE;
|
||||
|
||||
public boolean PACK_ASSETS_FROM_LIBRARIES;
|
||||
|
||||
public boolean RUN_PROGUARD;
|
||||
public String PROGUARD_CFG_PATH;
|
||||
|
||||
|
||||
+1
-63
@@ -17,37 +17,25 @@
|
||||
package org.jetbrains.android.actions;
|
||||
|
||||
import com.android.resources.ResourceFolderType;
|
||||
import com.android.resources.ResourceType;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.ui.TextFieldWithAutoCompletion;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.android.dom.layout.AndroidLayoutUtil;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
@@ -79,62 +67,12 @@ public class AndroidCreateLayoutFileAction extends CreateTypedResourceFileAction
|
||||
return doCreateAndNavigate(newName, directory, rootTag, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doNavigate(XmlFile file) {
|
||||
final Project project = file.getProject();
|
||||
final String preferredEditorProviderId = computePreferredEditorForLayoutFiles(project);
|
||||
super.doNavigate(file);
|
||||
|
||||
if (preferredEditorProviderId != null) {
|
||||
final FileEditorManager manager = FileEditorManager.getInstance(project);
|
||||
if (manager instanceof FileEditorManagerImpl) {
|
||||
final VirtualFile vFile = file.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
((FileEditorManagerImpl)manager).setSelectedEditor(vFile, preferredEditorProviderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getAllowedTagNames(@NotNull AndroidFacet facet) {
|
||||
return AndroidLayoutUtil.getPossibleRoots(facet);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String computePreferredEditorForLayoutFiles(Project project) {
|
||||
final EditorHistoryManager manager = EditorHistoryManager.getInstance(project);
|
||||
final Set<VirtualFile> resourceDirs = new HashSet<VirtualFile>();
|
||||
final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
|
||||
|
||||
for (AndroidFacet facet : facets) {
|
||||
final VirtualFile resourceDir = AndroidRootUtil.getResourceDir(facet);
|
||||
if (resourceDir != null) {
|
||||
resourceDirs.add(resourceDir);
|
||||
}
|
||||
}
|
||||
|
||||
final VirtualFile[] files = manager.getFiles();
|
||||
for (int i = files.length - 1; i >= 0; i--) {
|
||||
final VirtualFile file = files[i];
|
||||
final VirtualFile parent = file.getParent();
|
||||
|
||||
if (parent != null) {
|
||||
final String resType = AndroidCommonUtils.getResourceTypeByDirName(parent.getName());
|
||||
|
||||
if (ResourceType.LAYOUT.getName().equals(resType) && resourceDirs.contains(parent.getParent())) {
|
||||
final FileEditorProvider provider = manager.getSelectedProvider(file);
|
||||
|
||||
if (provider != null) {
|
||||
return provider.getEditorTypeId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public class MyDialog extends DialogWrapper {
|
||||
private final InputValidator myValidator;
|
||||
|
||||
@@ -150,7 +88,7 @@ public class AndroidCreateLayoutFileAction extends CreateTypedResourceFileAction
|
||||
setTitle(AndroidBundle.message("new.typed.resource.dialog.title", "Layout"));
|
||||
final List<String> tagNames = getSortedAllowedTagNames(facet);
|
||||
myRootElementField = new TextFieldWithAutoCompletion<String>(
|
||||
facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true);
|
||||
facet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(tagNames, null), true, null);
|
||||
myRootElementField.setText(myDefaultRootTag);
|
||||
myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
|
||||
myRootElementLabel.setLabelFor(myRootElementField);
|
||||
|
||||
@@ -213,7 +213,7 @@ public class CreateResourceFileDialog extends DialogWrapper {
|
||||
if (action != null) {
|
||||
final List<String> allowedTagNames = action.getSortedAllowedTagNames(myFacet);
|
||||
myRootElementField = new TextFieldWithAutoCompletion<String>(
|
||||
myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true);
|
||||
myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true, null);
|
||||
myRootElementField.setEnabled(allowedTagNames.size() > 1);
|
||||
myRootElementField.setText(!action.isChooseTagName() && myPredefinedResourceType != ResourceType.LAYOUT
|
||||
? action.getDefaultRootTag()
|
||||
|
||||
+6
-4
@@ -102,11 +102,13 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom
|
||||
if (assetsDir != null) {
|
||||
result.add(FileUtil.toSystemDependentName(assetsDir.getPath()));
|
||||
}
|
||||
for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
|
||||
final VirtualFile depAssetsDir = AndroidRootUtil.getAssetsDir(depFacet);
|
||||
if (facet.getConfiguration().PACK_ASSETS_FROM_LIBRARIES) {
|
||||
for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
|
||||
final VirtualFile depAssetsDir = AndroidRootUtil.getAssetsDir(depFacet);
|
||||
|
||||
if (depAssetsDir != null) {
|
||||
result.add(FileUtil.toSystemDependentName(depAssetsDir.getPath()));
|
||||
if (depAssetsDir != null) {
|
||||
result.add(FileUtil.toSystemDependentName(depAssetsDir.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user