mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ public class AnyExceptionBreakpointFactory extends BreakpointFactory{
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project) {
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class BreakpointFactory {
|
||||
|
||||
public BreakpointPanel createBreakpointPanel(final Project project, final DialogWrapper parentDialog) {
|
||||
BreakpointPanel panel = new BreakpointPanel(project,
|
||||
createBreakpointPropertiesPanel(project),
|
||||
createBreakpointPropertiesPanel(project, false),
|
||||
createBreakpointPanelActions(project, parentDialog),
|
||||
getBreakpointCategory(), getDisplayName(), getHelpID());
|
||||
configureBreakpointPanel(panel);
|
||||
@@ -66,7 +66,7 @@ public abstract class BreakpointFactory {
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project);
|
||||
public abstract BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact);
|
||||
|
||||
protected abstract BreakpointPanelAction[] createBreakpointPanelActions(Project project, DialogWrapper parentDialog);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.debugger.ui.breakpoints.BreakpointPropertiesPanel">
|
||||
<grid id="6570" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="6570" binding="myPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" 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="23" y="37" width="631" height="347"/>
|
||||
|
||||
+27
-1
@@ -38,6 +38,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
@@ -59,6 +60,7 @@ import java.util.List;
|
||||
public abstract class BreakpointPropertiesPanel {
|
||||
protected final Project myProject;
|
||||
private final Key<? extends Breakpoint> myBreakpointCategory;
|
||||
private boolean myCompact;
|
||||
private JPanel myPanel;
|
||||
private final DebuggerExpressionComboBox myConditionCombo;
|
||||
private final DebuggerExpressionComboBox myLogExpressionCombo;
|
||||
@@ -111,6 +113,20 @@ public abstract class BreakpointPropertiesPanel {
|
||||
return myMoreOptionsVisible;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myPanel = new JPanel() {
|
||||
@Override
|
||||
public boolean requestFocus(boolean b) {
|
||||
return super.requestFocus(b); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
super.requestFocus(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface Delegate {
|
||||
|
||||
void showActionsPanel();
|
||||
@@ -181,9 +197,10 @@ public abstract class BreakpointPropertiesPanel {
|
||||
panel.add(component, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public BreakpointPropertiesPanel(Project project, final Key<? extends Breakpoint> breakpointCategory) {
|
||||
public BreakpointPropertiesPanel(Project project, final Key<? extends Breakpoint> breakpointCategory, boolean compact) {
|
||||
myProject = project;
|
||||
myBreakpointCategory = breakpointCategory;
|
||||
myCompact = compact;
|
||||
|
||||
mySuspendPolicyGroup = new ButtonGroup();
|
||||
mySuspendPolicyGroup.add(mySuspendAllRadio);
|
||||
@@ -230,6 +247,15 @@ public abstract class BreakpointPropertiesPanel {
|
||||
});
|
||||
|
||||
myConditionCombo = new DebuggerExpressionComboBox(project, "LineBreakpoint condition");
|
||||
if (myCompact) {
|
||||
myPanel.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent event) {
|
||||
IdeFocusManager.findInstance().requestFocus(myConditionCombo, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
myLogExpressionCombo = new DebuggerExpressionComboBox(project, "LineBreakpoint logMessage");
|
||||
|
||||
final ComboBox baseBreakpointCombo = new ComboBox(100);
|
||||
|
||||
+3
-3
@@ -69,8 +69,8 @@ public class ExceptionBreakpointFactory extends BreakpointFactory{
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project) {
|
||||
return new ExceptionBreakpointPropertiesPanel(project);
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
return new ExceptionBreakpointPropertiesPanel(project, compact);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,7 +99,7 @@ public class ExceptionBreakpointFactory extends BreakpointFactory{
|
||||
|
||||
public BreakpointPanel createBreakpointPanel(final Project project, final DialogWrapper parentDialog) {
|
||||
BreakpointPanel panel = new BreakpointPanel(project,
|
||||
createBreakpointPropertiesPanel(project),
|
||||
createBreakpointPropertiesPanel(project, false),
|
||||
createBreakpointPanelActions(project, parentDialog),
|
||||
getBreakpointCategory(), getDisplayName(), getHelpID()){
|
||||
public void resetBreakpoints() {
|
||||
|
||||
+2
-2
@@ -36,8 +36,8 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane
|
||||
private JCheckBox myNotifyUncaughtCheckBox;
|
||||
private ExceptionBreakpoint myExceptionBreakpoint;
|
||||
|
||||
public ExceptionBreakpointPropertiesPanel(Project project) {
|
||||
super(project, ExceptionBreakpoint.CATEGORY);
|
||||
public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
super(project, ExceptionBreakpoint.CATEGORY, compact);
|
||||
}
|
||||
|
||||
protected ClassFilter createClassConditionFilter() {
|
||||
|
||||
+2
-2
@@ -65,8 +65,8 @@ public class FieldBreakpointFactory extends BreakpointFactory{
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project) {
|
||||
return new FieldBreakpointPropertiesPanel(project);
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
return new FieldBreakpointPropertiesPanel(project, compact);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
|
||||
private JCheckBox myWatchAccessCheckBox;
|
||||
private JCheckBox myWatchModificationCheckBox;
|
||||
|
||||
public FieldBreakpointPropertiesPanel(final Project project) {
|
||||
super(project, FieldBreakpoint.CATEGORY);
|
||||
public FieldBreakpointPropertiesPanel(final Project project, boolean compact) {
|
||||
super(project, FieldBreakpoint.CATEGORY, compact);
|
||||
}
|
||||
|
||||
protected JComponent createSpecialBox() {
|
||||
|
||||
+2
-2
@@ -54,8 +54,8 @@ public class LineBreakpointFactory extends BreakpointFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project) {
|
||||
return new LineBreakpointPropertiesPanel(project);
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
return new LineBreakpointPropertiesPanel(project, compact);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
public class LineBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
|
||||
public LineBreakpointPropertiesPanel(Project project) {
|
||||
super(project, LineBreakpoint.CATEGORY);
|
||||
public LineBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
super(project, LineBreakpoint.CATEGORY, compact);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -55,8 +55,8 @@ public class MethodBreakpointFactory extends BreakpointFactory{
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project) {
|
||||
return new MethodBreakpointPropertiesPanel(project);
|
||||
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
|
||||
return new MethodBreakpointPropertiesPanel(project, compact);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
|
||||
private JCheckBox myWatchEntryCheckBox;
|
||||
private JCheckBox myWatchExitCheckBox;
|
||||
|
||||
public MethodBreakpointPropertiesPanel(final Project project) {
|
||||
super(project, MethodBreakpoint.CATEGORY);
|
||||
public MethodBreakpointPropertiesPanel(final Project project, boolean compact) {
|
||||
super(project, MethodBreakpoint.CATEGORY, compact);
|
||||
}
|
||||
|
||||
protected JComponent createSpecialBox() {
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class JavaEditBreakpointAction extends EditBreakpointAction {
|
||||
}
|
||||
assert breakpointFactory != null : "can't find factory for breakpoint " + myBreakpointWithHighlighter;
|
||||
|
||||
final BreakpointPropertiesPanel propertiesPanel = breakpointFactory.createBreakpointPropertiesPanel(project);
|
||||
final BreakpointPropertiesPanel propertiesPanel = breakpointFactory.createBreakpointPropertiesPanel(project, true);
|
||||
propertiesPanel.initFrom(myBreakpointWithHighlighter, false);
|
||||
|
||||
final JComponent mainPanel = propertiesPanel.getPanel();
|
||||
|
||||
+16
-20
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.generation.ConstructorBodyGenerator;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.codeInsight.generation.PsiMethodMember;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
@@ -27,6 +28,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -34,7 +36,6 @@ import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -101,7 +102,7 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
|
||||
MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(constructors, false, true, project);
|
||||
chooser.setTitle(QuickFixBundle.message("super.class.constructors.chooser.title"));
|
||||
chooser.show();
|
||||
if (chooser.getExitCode() != MemberChooser.OK_EXIT_CODE) return;
|
||||
if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
|
||||
constructors = chooser.getSelectedElements(new PsiMethodMember[0]);
|
||||
isCopyJavadoc = chooser.isCopyJavadoc();
|
||||
}
|
||||
@@ -117,12 +118,12 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(targetClass.getProject()).getElementFactory().createClass("X");
|
||||
targetClass.addRangeAfter(psiClass.getLBrace(), psiClass.getRBrace(), targetClass.getLastChild());
|
||||
}
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
CodeStyleManager reformatter = CodeStyleManager.getInstance(project);
|
||||
JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), project);
|
||||
CodeStyleManager formatter = CodeStyleManager.getInstance(project);
|
||||
PsiMethod derived = null;
|
||||
for (PsiMethodMember candidate : constructors1) {
|
||||
PsiMethod base = candidate.getElement();
|
||||
derived = GenerateMembersUtil.substituteGenericMethod(base, candidate.getSubstitutor());
|
||||
derived = GenerateMembersUtil.substituteGenericMethod(base, candidate.getSubstitutor(), targetClass);
|
||||
|
||||
if (!isCopyJavadoc1) {
|
||||
final PsiDocComment docComment = derived.getDocComment();
|
||||
@@ -131,23 +132,18 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
final PsiIdentifier identifier = targetClass.getNameIdentifier();
|
||||
LOG.assertTrue(identifier != null, targetClass);
|
||||
derived.getNameIdentifier().replace(identifier);
|
||||
@NonNls StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("void foo () {\nsuper(");
|
||||
derived.setName(targetClass.getName());
|
||||
|
||||
PsiParameter[] params = derived.getParameterList().getParameters();
|
||||
for (int j = 0; j < params.length; j++) {
|
||||
PsiParameter param = params[j];
|
||||
buffer.append(param.getName());
|
||||
if (j < params.length - 1) buffer.append(",");
|
||||
ConstructorBodyGenerator generator = ConstructorBodyGenerator.INSTANCE.forLanguage(derived.getLanguage());
|
||||
if (generator != null) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
generator.start(buffer, derived.getName(), PsiParameter.EMPTY_ARRAY);
|
||||
generator.generateSuperCallIfNeeded(buffer, derived.getParameterList().getParameters());
|
||||
generator.finish(buffer);
|
||||
PsiMethod stub = factory.createMethodFromText(buffer.toString(), targetClass);
|
||||
derived.getBody().replace(stub.getBody());
|
||||
}
|
||||
buffer.append(");\n}");
|
||||
PsiMethod stub = factory.createMethodFromText(buffer.toString(), targetClass);
|
||||
|
||||
derived.getBody().replace(stub.getBody());
|
||||
derived = (PsiMethod)reformatter.reformat(derived);
|
||||
derived = (PsiMethod)formatter.reformat(derived);
|
||||
derived = (PsiMethod)JavaCodeStyleManager.getInstance(project).shortenClassReferences(derived);
|
||||
derived = (PsiMethod)GenerateMembersUtil.insert(targetClass, derived, null, true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.codeInsight.generation;
|
||||
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public interface ConstructorBodyGenerator {
|
||||
LanguageExtension<ConstructorBodyGenerator> INSTANCE = new LanguageExtension<ConstructorBodyGenerator>("com.intellij.constructorBodyGenerator");
|
||||
|
||||
void generateFieldInitialization(@NotNull StringBuilder buffer, @NotNull PsiField[] fields, @NotNull PsiParameter[] parameters);
|
||||
|
||||
void generateSuperCallIfNeeded(@NotNull StringBuilder buffer, @NotNull PsiParameter[] parameters);
|
||||
|
||||
StringBuilder start(StringBuilder buffer, @NotNull String name, @NotNull PsiParameter[] parameters);
|
||||
|
||||
void finish(StringBuilder builder);
|
||||
}
|
||||
+34
-26
@@ -211,7 +211,7 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
|
||||
public static PsiMethod generateConstructorPrototype(PsiClass aClass, PsiMethod baseConstructor, boolean copyJavaDoc, PsiField[] fields) throws IncorrectOperationException {
|
||||
PsiManager manager = aClass.getManager();
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
JVMElementFactory factory = JVMElementFactories.getFactory(aClass.getLanguage(), aClass.getProject());
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
|
||||
PsiMethod constructor = factory.createConstructor();
|
||||
@@ -235,37 +235,28 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls StringBuilder body = new StringBuilder();
|
||||
body.append("{\n");
|
||||
|
||||
boolean isNotEnum = false;
|
||||
if (baseConstructor != null){
|
||||
PsiClass superClass = aClass.getSuperClass();
|
||||
LOG.assertTrue(superClass != null);
|
||||
if (!CommonClassNames.JAVA_LANG_ENUM.equals(superClass.getQualifiedName())) {
|
||||
isNotEnum = true;
|
||||
if (baseConstructor instanceof PsiCompiledElement){ // to get some parameter names
|
||||
PsiClass dummyClass = factory.createClass("Dummy");
|
||||
PsiClass dummyClass = JVMElementFactories.getFactory(baseConstructor.getLanguage(), baseConstructor.getProject()).createClass("Dummy");
|
||||
baseConstructor = (PsiMethod)dummyClass.add(baseConstructor);
|
||||
}
|
||||
PsiParameter[] parms = baseConstructor.getParameterList().getParameters();
|
||||
for (PsiParameter parm : parms) {
|
||||
constructor.getParameterList().add(parm);
|
||||
}
|
||||
if (parms.length > 0){
|
||||
body.append("super(");
|
||||
for(int j = 0; j < parms.length; j++) {
|
||||
PsiParameter parm = parms[j];
|
||||
if (j > 0){
|
||||
body.append(",");
|
||||
}
|
||||
body.append(parm.getName());
|
||||
}
|
||||
body.append(");\n");
|
||||
PsiParameter newParam = factory.createParameter(parm.getName(), parm.getType());
|
||||
copyModifierList(factory, parm, newParam);
|
||||
constructor.getParameterList().add(newParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JavaCodeStyleManager javaStyle = JavaCodeStyleManager.getInstance(aClass.getProject());
|
||||
|
||||
List<PsiParameter> fieldParams = new ArrayList<PsiParameter>();
|
||||
for (PsiField field : fields) {
|
||||
String fieldName = field.getName();
|
||||
String name = javaStyle.variableNameToPropertyName(fieldName, VariableKind.FIELD);
|
||||
@@ -280,22 +271,39 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
}
|
||||
|
||||
constructor.getParameterList().add(parm);
|
||||
if (fieldName.equals(parmName)) {
|
||||
body.append("this.");
|
||||
fieldParams.add(parm);
|
||||
}
|
||||
|
||||
ConstructorBodyGenerator generator = ConstructorBodyGenerator.INSTANCE.forLanguage(aClass.getLanguage());
|
||||
if (generator != null) {
|
||||
@NonNls StringBuilder buffer = new StringBuilder();
|
||||
generator.start(buffer, constructor.getName(), PsiParameter.EMPTY_ARRAY);
|
||||
if (isNotEnum) {
|
||||
generator.generateSuperCallIfNeeded(buffer, baseConstructor.getParameterList().getParameters());
|
||||
}
|
||||
body.append(fieldName);
|
||||
body.append("=");
|
||||
body.append(parmName);
|
||||
body.append(";\n");
|
||||
generator.generateFieldInitialization(buffer, fields, fieldParams.toArray(new PsiParameter[fieldParams.size()]));
|
||||
generator.finish(buffer);
|
||||
PsiMethod stub = factory.createMethodFromText(buffer.toString(), aClass);
|
||||
constructor.getBody().replace(stub.getBody());
|
||||
}
|
||||
|
||||
body.append("}");
|
||||
PsiCodeBlock bodyBlock = factory.createCodeBlockFromText(body.toString(), null);
|
||||
constructor.getBody().replace(bodyBlock);
|
||||
constructor = (PsiMethod)codeStyleManager.reformat(constructor);
|
||||
return constructor;
|
||||
}
|
||||
|
||||
static void copyModifierList(JVMElementFactory factory, PsiParameter parm, PsiParameter newParam) {
|
||||
PsiModifierList modifierList = parm.getModifierList();
|
||||
PsiModifierList newMList = newParam.getModifierList();
|
||||
if (modifierList != null && newMList != null) {
|
||||
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
|
||||
newMList.add(factory.createAnnotationFromText(annotation.getText(), newParam));
|
||||
}
|
||||
for (@PsiModifier.ModifierConstant String m : PsiModifier.MODIFIERS) {
|
||||
newMList.setModifierProperty(m, parm.hasModifierProperty(m));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PsiModifier.ModifierConstant
|
||||
public static String getConstructorModifier(final PsiClass aClass) {
|
||||
String modifier = PsiModifier.PUBLIC;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class GenerateMembersUtil {
|
||||
editor.getSelectionModel().removeSelection();
|
||||
}
|
||||
|
||||
public static PsiElement insert(PsiClass aClass, PsiMember member, PsiElement anchor, boolean before) throws IncorrectOperationException {
|
||||
public static PsiElement insert(@NotNull PsiClass aClass, @NotNull PsiMember member, @Nullable PsiElement anchor, boolean before) throws IncorrectOperationException {
|
||||
if (member instanceof PsiMethod) {
|
||||
if (!aClass.isInterface()) {
|
||||
final PsiParameter[] parameters = ((PsiMethod)member).getParameterList().getParameters();
|
||||
@@ -228,9 +228,15 @@ public class GenerateMembersUtil {
|
||||
|
||||
public static PsiMethod substituteGenericMethod(PsiMethod method,
|
||||
final PsiSubstitutor substitutor,
|
||||
final PsiElement target) {
|
||||
@Nullable final PsiElement target) {
|
||||
Project project = method.getProject();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
|
||||
final JVMElementFactory factory;
|
||||
if (target != null) {
|
||||
factory = JVMElementFactories.getFactory(target.getLanguage(), method.getProject());
|
||||
}
|
||||
else {
|
||||
factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
|
||||
}
|
||||
|
||||
try {
|
||||
PsiType returnType = method.getReturnType();
|
||||
@@ -238,7 +244,7 @@ public class GenerateMembersUtil {
|
||||
PsiMethod newMethod;
|
||||
if (method.isConstructor()) {
|
||||
newMethod = factory.createConstructor();
|
||||
newMethod.getNameIdentifier().replace(factory.createIdentifier(method.getName()));
|
||||
newMethod.setName(method.getName());
|
||||
}
|
||||
else {
|
||||
final PsiType substitutedReturnType = substituteType(substitutor, returnType);
|
||||
@@ -292,10 +298,15 @@ public class GenerateMembersUtil {
|
||||
if (paramName == null) paramName = "p" + i;
|
||||
|
||||
PsiParameter newParameter = factory.createParameter(paramName, substituted);
|
||||
if (parameter.getLanguage() == JavaLanguage.INSTANCE) {
|
||||
if (parameter.getLanguage() == newParameter.getLanguage()) {
|
||||
PsiModifierList modifierList = newParameter.getModifierList();
|
||||
modifierList = (PsiModifierList)modifierList.replace(parameter.getModifierList());
|
||||
processAnnotations(project, modifierList, moduleScope);
|
||||
if (parameter.getLanguage() == JavaLanguage.INSTANCE) {
|
||||
processAnnotations(project, modifierList, moduleScope);
|
||||
}
|
||||
}
|
||||
else {
|
||||
GenerateConstructorHandler.copyModifierList(factory, parameter, newParameter);
|
||||
}
|
||||
newMethod.getParameterList().add(newParameter);
|
||||
}
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.codeInsight.generation;
|
||||
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class JavaConstructorBodyWithSuperCallGenerator implements ConstructorBodyGenerator {
|
||||
@Override
|
||||
public void generateFieldInitialization(@NotNull StringBuilder buffer,
|
||||
@NotNull PsiField[] fields,
|
||||
@NotNull PsiParameter[] parameters) {
|
||||
for (int i = 0, length = fields.length; i < length; i++) {
|
||||
String fieldName = fields[i].getName();
|
||||
String paramName = parameters[i].getName();
|
||||
if (fieldName.equals(paramName)) {
|
||||
buffer.append("this.");
|
||||
}
|
||||
buffer.append(fieldName);
|
||||
buffer.append("=");
|
||||
buffer.append(paramName);
|
||||
buffer.append(";\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSuperCallIfNeeded(@NotNull StringBuilder buffer, @NotNull PsiParameter[] parameters) {
|
||||
if (parameters.length > 0) {
|
||||
buffer.append("super(");
|
||||
for (int j = 0; j < parameters.length; j++) {
|
||||
PsiParameter param = parameters[j];
|
||||
buffer.append(param.getName());
|
||||
if (j < parameters.length - 1) buffer.append(",");
|
||||
}
|
||||
buffer.append(");\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuilder start(StringBuilder buffer, @NotNull String name, @NotNull PsiParameter[] parameters) {
|
||||
buffer.append("public ").append(name).append("(");
|
||||
for (PsiParameter parameter : parameters) {
|
||||
buffer.append(parameter.getType().getPresentableText()).append(' ').append(parameter.getName()).append(',');
|
||||
}
|
||||
if (parameters.length > 0) {
|
||||
buffer.delete(buffer.length() - 1, buffer.length());
|
||||
}
|
||||
buffer.append("){\n");
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(StringBuilder buffer) {
|
||||
buffer.append('}');
|
||||
}
|
||||
}
|
||||
+15
-2
@@ -284,8 +284,9 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
processParameter(project, ((ParameterClassMember)selectedElements.get(0)).getParameter(), isInteractive);
|
||||
} else {
|
||||
//do not ask for names in batch
|
||||
final HashSet<String> usedNames = new HashSet<String>();
|
||||
for (ClassMember selectedElement : selectedElements) {
|
||||
processParameter(project, ((ParameterClassMember)selectedElement).getParameter(), false);
|
||||
processParameter(project, ((ParameterClassMember)selectedElement).getParameter(), false, usedNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,6 +301,13 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
private static void processParameter(final Project project,
|
||||
final PsiParameter myParameter,
|
||||
boolean isInteractive) {
|
||||
processParameter(project, myParameter, isInteractive, new HashSet<String>());
|
||||
}
|
||||
|
||||
private static void processParameter(final Project project,
|
||||
final PsiParameter myParameter,
|
||||
boolean isInteractive,
|
||||
final Set<String> usedNames) {
|
||||
IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
|
||||
final PsiType[] types = getTypes(myParameter);
|
||||
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
|
||||
@@ -347,7 +355,12 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
}
|
||||
else {
|
||||
isFinalToCalc = !isMethodStatic && method.isConstructor();
|
||||
fieldNameToCalc = names[0];
|
||||
if (usedNames.add(names[0])) {
|
||||
fieldNameToCalc = names[0];
|
||||
}
|
||||
else {
|
||||
fieldNameToCalc = JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(names[0], myParameter, true);
|
||||
}
|
||||
type= types[0];
|
||||
}
|
||||
|
||||
|
||||
+17
-2
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.navigation.actions;
|
||||
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -22,9 +24,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaTypeDeclarationProvider implements TypeDeclarationProvider {
|
||||
public class JavaTypeDeclarationProvider implements TypeDeclarationPlaceAwareProvider {
|
||||
@Override
|
||||
public PsiElement[] getSymbolTypeDeclarations(PsiElement symbol) {
|
||||
return getSymbolTypeDeclarations(symbol, null, -1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement[] getSymbolTypeDeclarations(final PsiElement targetElement) {
|
||||
@Override
|
||||
public PsiElement[] getSymbolTypeDeclarations(PsiElement targetElement, Editor editor, int offset) {
|
||||
PsiType type;
|
||||
if (targetElement instanceof PsiVariable){
|
||||
type = ((PsiVariable)targetElement).getType();
|
||||
@@ -36,6 +44,13 @@ public class JavaTypeDeclarationProvider implements TypeDeclarationProvider {
|
||||
return null;
|
||||
}
|
||||
if (type == null) return null;
|
||||
if (editor != null) {
|
||||
final PsiReference reference = TargetElementUtilBase.findReference(editor, offset);
|
||||
if (reference instanceof PsiJavaReference) {
|
||||
final JavaResolveResult resolveResult = ((PsiJavaReference)reference).advancedResolve(true);
|
||||
type = resolveResult.getSubstitutor().substitute(type);
|
||||
}
|
||||
}
|
||||
PsiClass psiClass = PsiUtil.resolveClassInType(type);
|
||||
return psiClass == null ? null : new PsiElement[] {psiClass};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -197,7 +197,7 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
|
||||
return new ProjectViewTree(treeModel) {
|
||||
return new ProjectViewTree(myProject, treeModel) {
|
||||
public String toString() {
|
||||
return getTitle() + " " + super.toString();
|
||||
}
|
||||
|
||||
@@ -127,4 +127,6 @@ public interface JVMElementFactory {
|
||||
|
||||
@NotNull
|
||||
PsiElement createExpressionFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
PsiElement createReferenceElementByType(PsiClassType type);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -249,7 +249,7 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
|
||||
|
||||
@Override
|
||||
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
|
||||
return new ProjectViewTree(treeModel) {
|
||||
return new ProjectViewTree(myProject, treeModel) {
|
||||
@Override
|
||||
public DefaultMutableTreeNode getSelectedNode() {
|
||||
return null;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.io.MappingFailedException;
|
||||
import com.intellij.util.io.PersistentEnumerator;
|
||||
import org.jetbrains.ether.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.*;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.api.GlobalOptions;
|
||||
@@ -25,11 +26,9 @@ import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
import org.jetbrains.jps.server.ProjectDescriptor;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -40,6 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class IncProjectBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder");
|
||||
private static final Logger LocalLOG = Logger.getInstance("#org.jetbrains.jps.incremental.Builder");
|
||||
|
||||
public static final String COMPILE_SERVER_NAME = "COMPILE SERVER";
|
||||
private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index";
|
||||
@@ -205,6 +205,24 @@ public class IncProjectBuilder {
|
||||
context.processMessage(new ProgressMessage("Running 'after' tasks"));
|
||||
runTasks(context, myBuilderRegistry.getAfterTasks());
|
||||
|
||||
if (/*LocalLOG.isDebugEnabled()*/ false) {
|
||||
final Mappings mappings = myProjectDescriptor.dataManager.getMappings();
|
||||
final String fileName = Utils.getSystemRoot() + File.separator + "snapshot-" + new SimpleDateFormat("dd-MM-yy(hh:mm:ss)").format(new Date()) + ".log";
|
||||
|
||||
try {
|
||||
final PrintStream stream = new PrintStream(fileName);
|
||||
|
||||
stream.println("Mappings:");
|
||||
mappings.toStream(stream);
|
||||
stream.println("End Of Mappings");
|
||||
|
||||
stream.close();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
context.processMessage(new ProgressMessage("Finished, saving caches..."));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.ether.RW;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.*;
|
||||
|
||||
@@ -322,18 +323,16 @@ public class ClassRepr extends Proto {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBuffer(final DependencyContext context, final StringBuffer buf) {
|
||||
super.toBuffer(context, buf);
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
super.toStream(context, stream);
|
||||
|
||||
buf.append(" Filename : ");
|
||||
buf.append(context.getValue(fileName));
|
||||
buf.append("\n");
|
||||
stream.print(" Filename : ");
|
||||
stream.println(context.getValue(fileName));
|
||||
|
||||
buf.append(" Superclass : ");
|
||||
buf.append(superClass == null ? "<null>" : superClass.getDescr(context));
|
||||
buf.append("\n");
|
||||
stream.print(" Superclass : ");
|
||||
stream.println(superClass == null ? "<null>" : superClass.getDescr(context));
|
||||
|
||||
buf.append(" Interfaces : ");
|
||||
stream.print(" Interfaces : ");
|
||||
final TypeRepr.AbstractType[] is = interfaces.toArray(new TypeRepr.AbstractType[interfaces.size()]);
|
||||
Arrays.sort(is, new Comparator<TypeRepr.AbstractType>() {
|
||||
@Override
|
||||
@@ -342,33 +341,30 @@ public class ClassRepr extends Proto {
|
||||
}
|
||||
});
|
||||
for (final TypeRepr.AbstractType t : is) {
|
||||
buf.append(t.getDescr(context));
|
||||
buf.append("; ");
|
||||
stream.print(t.getDescr(context));
|
||||
stream.print("; ");
|
||||
}
|
||||
buf.append("\n");
|
||||
stream.println();
|
||||
|
||||
buf.append(" Targets : ");
|
||||
stream.print(" Targets : ");
|
||||
final ElemType[] es = targets.toArray(new ElemType[targets.size()]);
|
||||
Arrays.sort(es);
|
||||
for (final ElemType e : es) {
|
||||
buf.append(e);
|
||||
buf.append("; ");
|
||||
stream.print(e);
|
||||
stream.print("; ");
|
||||
}
|
||||
buf.append("\n");
|
||||
stream.println();
|
||||
|
||||
buf.append(" Policy : ");
|
||||
buf.append(policy);
|
||||
buf.append("\n");
|
||||
stream.print(" Policy : ");
|
||||
stream.println(policy);
|
||||
|
||||
buf.append(" Outer class: ");
|
||||
buf.append(context.getValue(outerClassName));
|
||||
buf.append("\n");
|
||||
stream.print(" Outer class: ");
|
||||
stream.println(context.getValue(outerClassName));
|
||||
|
||||
buf.append(" Local class: ");
|
||||
buf.append(isLocal);
|
||||
buf.append("\n");
|
||||
stream.print(" Local class: ");
|
||||
stream.println(isLocal);
|
||||
|
||||
buf.append(" Fields:\n");
|
||||
stream.println(" Fields:");
|
||||
final FieldRepr[] fs = fields.toArray(new FieldRepr[fields.size()]);
|
||||
Arrays.sort(fs, new Comparator<FieldRepr>() {
|
||||
@Override
|
||||
@@ -381,11 +377,11 @@ public class ClassRepr extends Proto {
|
||||
}
|
||||
});
|
||||
for (final FieldRepr f : fs) {
|
||||
f.toBuffer(context, buf);
|
||||
f.toStream(context, stream);
|
||||
}
|
||||
buf.append(" End Of Fields\n");
|
||||
stream.println(" End Of Fields");
|
||||
|
||||
buf.append(" Methods:\n");
|
||||
stream.println(" Methods:");
|
||||
final MethodRepr[] ms = methods.toArray(new MethodRepr[methods.size()]);
|
||||
Arrays.sort(ms, new Comparator<MethodRepr>() {
|
||||
@Override
|
||||
@@ -425,8 +421,8 @@ public class ClassRepr extends Proto {
|
||||
}
|
||||
});
|
||||
for (final MethodRepr m : ms) {
|
||||
m.toBuffer(context, buf);
|
||||
m.toStream(context, stream);
|
||||
}
|
||||
buf.append(" End Of Methods\n");
|
||||
stream.println(" End Of Methods");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.jetbrains.ether.dependencyView;
|
||||
|
||||
import gnu.trove.TIntIntProcedure;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: db
|
||||
@@ -24,7 +26,7 @@ import gnu.trove.TIntIntProcedure;
|
||||
* Time: 23:48
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
abstract class IntIntMaplet implements StringBufferizable{
|
||||
abstract class IntIntMaplet implements Streamable {
|
||||
abstract boolean containsKey(final int key);
|
||||
abstract int get(final int key);
|
||||
abstract void put(final int key, final int value);
|
||||
@@ -34,15 +36,14 @@ abstract class IntIntMaplet implements StringBufferizable{
|
||||
abstract void forEachEntry(TIntIntProcedure proc);
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toBuffer (final DependencyContext context, final StringBuffer buf) {
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
forEachEntry(new TIntIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(final int a, final int b) {
|
||||
buf.append(" ");
|
||||
buf.append(context.getValue(a));
|
||||
buf.append(" -> ");
|
||||
buf.append(context.getValue(b));
|
||||
buf.append("\n");
|
||||
stream.print(" ");
|
||||
stream.print(context.getValue(a));
|
||||
stream.print(" -> ");
|
||||
stream.println(context.getValue(b));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,6 +19,8 @@ import gnu.trove.TIntHashSet;
|
||||
import gnu.trove.TIntObjectProcedure;
|
||||
import gnu.trove.TIntProcedure;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: db
|
||||
@@ -26,7 +28,7 @@ import gnu.trove.TIntProcedure;
|
||||
* Time: 21:01
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
abstract class IntIntMultiMaplet implements StringBufferizable{
|
||||
abstract class IntIntMultiMaplet implements Streamable {
|
||||
abstract boolean containsKey(final int key);
|
||||
|
||||
abstract TIntHashSet get(final int key);
|
||||
@@ -53,25 +55,24 @@ abstract class IntIntMultiMaplet implements StringBufferizable{
|
||||
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toBuffer(final DependencyContext context, final StringBuffer buf) {
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
forEachEntry(new TIntObjectProcedure<TIntHashSet>() {
|
||||
@Override
|
||||
public boolean execute(final int a, final TIntHashSet b) {
|
||||
buf.append(" Key: ");
|
||||
buf.append(context.getValue(a));
|
||||
buf.append("\n Values:\n");
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
b.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(final int value) {
|
||||
buf.append(" ");
|
||||
buf.append(context.getValue(value));
|
||||
buf.append("\n");
|
||||
stream.print(" ");
|
||||
stream.println(context.getValue(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
buf.append(" End Of Values\n");
|
||||
stream.println(" End Of Values");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.jetbrains.ether.dependencyView;
|
||||
|
||||
import gnu.trove.TIntObjectProcedure;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ import java.util.Collection;
|
||||
* Time: 21:01
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
abstract class IntObjectMultiMaplet<V extends StringBufferizable> implements StringBufferizable {
|
||||
abstract class IntObjectMultiMaplet<V extends Streamable> implements Streamable {
|
||||
abstract boolean containsKey(final int key);
|
||||
|
||||
abstract Collection<V> get(final int key);
|
||||
@@ -53,19 +54,19 @@ abstract class IntObjectMultiMaplet<V extends StringBufferizable> implements Str
|
||||
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toBuffer(final DependencyContext context, final StringBuffer buf) {
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
forEachEntry(new TIntObjectProcedure<Collection<V>>() {
|
||||
@Override
|
||||
public boolean execute(final int a, final Collection<V> b) {
|
||||
buf.append(" Key: ");
|
||||
buf.append(context.getValue(a));
|
||||
buf.append("\n Values:\n");
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
for (final V value : b) {
|
||||
value.toBuffer(context, buf);
|
||||
value.toStream(context, stream);
|
||||
}
|
||||
|
||||
buf.append(" End Of Values\n");
|
||||
stream.println(" End Of Values");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import java.util.Collections;
|
||||
* Time: 15:38
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class IntObjectPersistentMultiMaplet<V extends StringBufferizable> extends IntObjectMultiMaplet<V> {
|
||||
class IntObjectPersistentMultiMaplet<V extends Streamable> extends IntObjectMultiMaplet<V> {
|
||||
private static final Collection NULL_COLLECTION = Collections.emptySet();
|
||||
private static final int CACHE_SIZE = 128;
|
||||
private final PersistentHashMap<Integer, Collection<V>> myMap;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Collection;
|
||||
* Time: 15:38
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class IntObjectTransientMultiMaplet<V extends StringBufferizable> extends IntObjectMultiMaplet<V> {
|
||||
class IntObjectTransientMultiMaplet<V extends Streamable> extends IntObjectMultiMaplet<V> {
|
||||
|
||||
private final TIntObjectHashMap<Collection<V>> myMap = new TIntObjectHashMap<Collection<V>>();
|
||||
private final CollectionFactory<V> myCollectionFactory;
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.asm4.Opcodes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.*;
|
||||
|
||||
@@ -2050,8 +2051,8 @@ public class Mappings {
|
||||
myDebugS.debug(comment, s);
|
||||
}
|
||||
|
||||
public void toBuffer(final StringBuffer buf) {
|
||||
final StringBufferizable[] data = {
|
||||
public void toStream (final PrintStream stream) {
|
||||
final Streamable[] data = {
|
||||
myClassToSubclasses,
|
||||
myClassToClassDependency,
|
||||
mySourceFileToClasses,
|
||||
@@ -2070,15 +2071,13 @@ public class Mappings {
|
||||
};
|
||||
|
||||
for (int i = 0; i<data.length; i++) {
|
||||
buf.append("Begin Of ");
|
||||
buf.append(info[i]);
|
||||
buf.append("\n");
|
||||
stream.print("Begin Of ");
|
||||
stream.println(info[i]);
|
||||
|
||||
data[i].toBuffer(myContext, buf);
|
||||
data[i].toStream(myContext, stream);
|
||||
|
||||
buf.append("End Of ");
|
||||
buf.append(info[i]);
|
||||
buf.append("\n");
|
||||
stream.print("End Of ");
|
||||
stream.println(info[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.ether.RW;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
@@ -202,14 +203,14 @@ class MethodRepr extends ProtoMember {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBuffer(final DependencyContext context, final StringBuffer buf) {
|
||||
super.toBuffer(context, buf);
|
||||
buf.append(" Arguments : ");
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
super.toStream(context, stream);
|
||||
stream.print(" Arguments : ");
|
||||
for (TypeRepr.AbstractType t : argumentTypes) {
|
||||
buf.append(t.getDescr(context));
|
||||
buf.append("; ");
|
||||
stream.print(t.getDescr(context));
|
||||
stream.print("; ");
|
||||
}
|
||||
buf.append("\n");
|
||||
stream.println();
|
||||
|
||||
final TypeRepr.AbstractType[] es = exceptions.toArray(new TypeRepr.AbstractType[exceptions.size()]);
|
||||
Arrays.sort(es, new Comparator<TypeRepr.AbstractType>() {
|
||||
@@ -218,11 +219,11 @@ class MethodRepr extends ProtoMember {
|
||||
return o1.getDescr(context).compareTo(o2.getDescr(context));
|
||||
}
|
||||
});
|
||||
buf.append(" Exceptions: ");
|
||||
stream.print(" Exceptions: ");
|
||||
for (final TypeRepr.AbstractType e : es) {
|
||||
buf.append(e.getDescr(context));
|
||||
buf.append("; ");
|
||||
stream.print(e.getDescr(context));
|
||||
stream.print("; ");
|
||||
}
|
||||
buf.append("\n");
|
||||
stream.println();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.ether.RW;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -14,7 +15,7 @@ import java.io.IOException;
|
||||
* Time: 17:57
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class Proto implements RW.Savable, StringBufferizable {
|
||||
class Proto implements RW.Savable, Streamable {
|
||||
public final int access;
|
||||
public final int signature;
|
||||
public final int name;
|
||||
@@ -102,17 +103,19 @@ class Proto implements RW.Savable, StringBufferizable {
|
||||
};
|
||||
}
|
||||
|
||||
public void toBuffer (final DependencyContext context, final StringBuffer buf) {
|
||||
buf.append(" Access : ");
|
||||
buf.append(access);
|
||||
buf.append("\n");
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
final String d = this instanceof ClassRepr ? " " : " ";
|
||||
|
||||
buf.append(" Signature: ");
|
||||
buf.append(context.getValue(signature));
|
||||
buf.append("\n");
|
||||
stream.print(d);
|
||||
stream.print("Access : ");
|
||||
stream.println(access);
|
||||
|
||||
buf.append(" Name : ");
|
||||
buf.append(context.getValue(name));
|
||||
buf.append("\n");
|
||||
stream.print(d);
|
||||
stream.print("Signature: ");
|
||||
stream.println(context.getValue(signature));
|
||||
|
||||
stream.print(d);
|
||||
stream.print("Name : ");
|
||||
stream.println(context.getValue(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.jetbrains.asm4.Type;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -180,14 +181,12 @@ abstract class ProtoMember extends Proto {
|
||||
};
|
||||
}
|
||||
|
||||
public void toBuffer (final DependencyContext context, final StringBuffer buf) {
|
||||
super.toBuffer(context, buf);
|
||||
buf.append(" Type : ");
|
||||
buf.append(type.getDescr(context));
|
||||
buf.append("\n");
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
super.toStream(context, stream);
|
||||
stream.print(" Type : ");
|
||||
stream.println(type.getDescr(context));
|
||||
|
||||
buf.append(" Value : ");
|
||||
buf.append(value == null ? "<null>" : value.toString());
|
||||
buf.append("\n");
|
||||
stream.print(" Value : ");
|
||||
stream.println(value == null ? "<null>" : value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.ether.dependencyView;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: db
|
||||
@@ -8,6 +10,6 @@ package org.jetbrains.ether.dependencyView;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
interface StringBufferizable {
|
||||
void toBuffer(DependencyContext context, StringBuffer buf);
|
||||
interface Streamable {
|
||||
void toStream(DependencyContext context, PrintStream stream);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.ether.RW;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ class UsageRepr {
|
||||
|
||||
}
|
||||
|
||||
public static class Cluster implements RW.Savable, StringBufferizable {
|
||||
public static class Cluster implements RW.Savable, Streamable {
|
||||
private final Map<Usage, TIntHashSet> myUsageToDependenciesMap = new HashMap<Usage, TIntHashSet>(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR);
|
||||
|
||||
public Cluster() {
|
||||
@@ -128,16 +129,16 @@ class UsageRepr {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBuffer(DependencyContext context, StringBuffer buf) {
|
||||
public void toStream(DependencyContext context, PrintStream stream) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class Usage implements RW.Savable, StringBufferizable {
|
||||
public static abstract class Usage implements RW.Savable, Streamable {
|
||||
public abstract int getOwner();
|
||||
|
||||
@Override
|
||||
public void toBuffer(DependencyContext context, StringBuffer buf) {
|
||||
public void toStream(DependencyContext context, PrintStream stream) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 1.3 KiB |
+13
-6
@@ -32,7 +32,7 @@ import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -107,16 +107,17 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements
|
||||
offset);
|
||||
|
||||
if (targetElement != null) {
|
||||
final PsiElement[] symbolType = getSymbolTypeDeclarations(targetElement);
|
||||
final PsiElement[] symbolType = getSymbolTypeDeclarations(targetElement, editor, offset);
|
||||
return symbolType == null ? PsiElement.EMPTY_ARRAY : symbolType;
|
||||
}
|
||||
|
||||
final PsiReference psiReference = TargetElementUtilBase.findReference(editor, offset);
|
||||
if (psiReference instanceof PsiPolyVariantReference) {
|
||||
final ResolveResult[] results = ((PsiPolyVariantReference)psiReference).multiResolve(false);
|
||||
Set<PsiElement> types = new THashSet<PsiElement>();
|
||||
|
||||
for(ResolveResult r: results) {
|
||||
final PsiElement[] declarations = getSymbolTypeDeclarations(r.getElement());
|
||||
final PsiElement[] declarations = getSymbolTypeDeclarations(r.getElement(), editor, offset);
|
||||
if (declarations != null) {
|
||||
for (PsiElement declaration : declarations) {
|
||||
assert declaration != null;
|
||||
@@ -125,16 +126,22 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements
|
||||
}
|
||||
}
|
||||
|
||||
if (!types.isEmpty()) return PsiUtilBase.toPsiElementArray(types);
|
||||
if (!types.isEmpty()) return PsiUtilCore.toPsiElementArray(types);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement[] getSymbolTypeDeclarations(final PsiElement targetElement) {
|
||||
private static PsiElement[] getSymbolTypeDeclarations(final PsiElement targetElement, Editor editor, int offset) {
|
||||
for(TypeDeclarationProvider provider: Extensions.getExtensions(TypeDeclarationProvider.EP_NAME)) {
|
||||
PsiElement[] result = provider.getSymbolTypeDeclarations(targetElement);
|
||||
PsiElement[] result;
|
||||
if (provider instanceof TypeDeclarationPlaceAwareProvider) {
|
||||
result = ((TypeDeclarationPlaceAwareProvider)provider).getSymbolTypeDeclarations(targetElement, editor, offset);
|
||||
}
|
||||
else {
|
||||
result = provider.getSymbolTypeDeclarations(targetElement);
|
||||
}
|
||||
if (result != null) return result;
|
||||
}
|
||||
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.codeInsight.navigation.actions;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 4/25/12
|
||||
*/
|
||||
public interface TypeDeclarationPlaceAwareProvider extends TypeDeclarationProvider {
|
||||
@Nullable
|
||||
PsiElement[] getSymbolTypeDeclarations(PsiElement symbol, Editor editor, int offset);
|
||||
}
|
||||
+19
-6
@@ -23,12 +23,12 @@ package com.intellij.codeInspection.ex;
|
||||
import com.intellij.codeInspection.CommonProblemDescriptor;
|
||||
import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.codeInspection.ui.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -165,7 +165,7 @@ public abstract class InspectionRVContentProvider {
|
||||
}
|
||||
LOG.assertTrue(childNode instanceof RefElementNode, childNode.getClass().getName());
|
||||
final RefElementNode elementNode = (RefElementNode)childNode;
|
||||
final Set<RefElementNode> parentNodes = new HashSet<RefElementNode>();
|
||||
final Set<RefElementNode> parentNodes = new LinkedHashSet<RefElementNode>();
|
||||
if (pNode.getPackageName() != null) {
|
||||
parentNodes.add(elementNode);
|
||||
} else {
|
||||
@@ -231,18 +231,18 @@ public abstract class InspectionRVContentProvider {
|
||||
return refElementNode;
|
||||
}
|
||||
else {
|
||||
refElementNode.add(prevNode);
|
||||
insertByIndex(prevNode, refElementNode);
|
||||
return nodeToBeAdded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!firstLevel) {
|
||||
currentNode.add(prevNode);
|
||||
insertByIndex(prevNode, currentNode);
|
||||
}
|
||||
final UserObjectContainer owner = container.getOwner();
|
||||
if (owner == null) {
|
||||
parentNode.add(currentNode);
|
||||
insertByIndex(currentNode, parentNode);
|
||||
return nodeToBeAdded;
|
||||
}
|
||||
container = owner;
|
||||
@@ -290,7 +290,7 @@ public abstract class InspectionRVContentProvider {
|
||||
|
||||
protected static void add(@Nullable final DefaultTreeModel model, final InspectionTreeNode child, final InspectionTreeNode parent) {
|
||||
if (model == null) {
|
||||
parent.add(child);
|
||||
insertByIndex(child, parent);
|
||||
}
|
||||
else {
|
||||
if (parent.getIndex(child) < 0) {
|
||||
@@ -299,6 +299,19 @@ public abstract class InspectionRVContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static void insertByIndex(InspectionTreeNode child, InspectionTreeNode parent) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
parent.add(child);
|
||||
return;
|
||||
}
|
||||
final int i = TreeUtil.indexedBinarySearch(parent, child, InspectionResultsViewComparator.getInstance());
|
||||
if (i >= 0){
|
||||
parent.add(child);
|
||||
return;
|
||||
}
|
||||
parent.insert(child, -i -1);
|
||||
}
|
||||
|
||||
private static void processDepth(@Nullable DefaultTreeModel model, final InspectionTreeNode child, final InspectionTreeNode current) {
|
||||
InspectionTreeNode[] children = new InspectionTreeNode[child.getChildCount()];
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
|
||||
@@ -712,7 +712,8 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
final List<T> tasks = new ArrayList<T>();
|
||||
if (includeOnlyActiveTasks) {
|
||||
final List<RunnerAndConfigurationSettings> checkedTemplates = new ArrayList<RunnerAndConfigurationSettings>();
|
||||
for (RunnerAndConfigurationSettings settings : myConfigurations.values()) {
|
||||
List<RunnerAndConfigurationSettings> settingsList = new ArrayList<RunnerAndConfigurationSettings>(myConfigurations.values());
|
||||
for (RunnerAndConfigurationSettings settings : settingsList) {
|
||||
final List<BeforeRunTask> runTasks = getBeforeRunTasks(settings.getConfiguration());
|
||||
for (BeforeRunTask task : runTasks) {
|
||||
if (task != null && task.isEnabled() && task.getProviderId() == taskProviderID) {
|
||||
@@ -822,7 +823,10 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
if (tasks != null) {
|
||||
return getCopies(tasks, includeOnlyActiveTasks);
|
||||
}
|
||||
return getTemplateBeforeRunTask(settings, includeOnlyActiveTasks);
|
||||
}
|
||||
|
||||
private List<BeforeRunTask> getTemplateBeforeRunTask(RunConfiguration settings, boolean includeOnlyActiveTasks) {
|
||||
final RunnerAndConfigurationSettings template = getConfigurationTemplate(settings.getFactory());
|
||||
final List<BeforeRunTask> templateTasks = myConfigurationToBeforeTasksMap.get(template.getConfiguration());
|
||||
if (templateTasks != null) {
|
||||
@@ -868,7 +872,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, List<BeforeRunTask> tasks) {
|
||||
List<BeforeRunTask> templates = getBeforeRunTasks(runConfiguration);//here may be some disabled templates
|
||||
List<BeforeRunTask> templates = getTemplateBeforeRunTask(runConfiguration, false);
|
||||
Set<Key<BeforeRunTask>> idsToSet = new HashSet<Key<BeforeRunTask>>();
|
||||
List<BeforeRunTask> result = new ArrayList<BeforeRunTask>(tasks);
|
||||
for (BeforeRunTask task : tasks) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -77,7 +77,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
|
||||
return new ProjectViewTree(treeModel) {
|
||||
return new ProjectViewTree(myProject, treeModel) {
|
||||
public String toString() {
|
||||
return getTitle() + " " + super.toString();
|
||||
}
|
||||
|
||||
@@ -21,10 +21,11 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.ide.util.treeView.NodeRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiDirectoryContainer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.ui.tabs.FileColorManagerImpl;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,18 +38,23 @@ import java.awt.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class ProjectViewTree extends DnDAwareTree {
|
||||
protected ProjectViewTree(TreeModel model) {
|
||||
private final Project myProject;
|
||||
|
||||
protected ProjectViewTree(Project project, TreeModel model) {
|
||||
super(model);
|
||||
myProject = project;
|
||||
|
||||
final NodeRenderer cellRenderer = new NodeRenderer();
|
||||
cellRenderer.setOpaque(false);
|
||||
cellRenderer.setIconOpaque(false);
|
||||
setCellRenderer(cellRenderer);
|
||||
cellRenderer.setTransparentIconBackground(true);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public abstract DefaultMutableTreeNode getSelectedNode();
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
public final int getToggleClickCount() {
|
||||
final DefaultMutableTreeNode selectedNode = getSelectedNode();
|
||||
@@ -66,7 +72,14 @@ public abstract class ProjectViewTree extends DnDAwareTree {
|
||||
|
||||
@Override
|
||||
public boolean isFileColorsEnabled() {
|
||||
return FileColorManagerImpl._isEnabled() && FileColorManagerImpl._isEnabledForProjectView();
|
||||
final boolean enabled = FileColorManagerImpl._isEnabled() && FileColorManagerImpl._isEnabledForProjectView();
|
||||
final boolean opaque = isOpaque();
|
||||
if (enabled && opaque) {
|
||||
setOpaque(false);
|
||||
} else if (!enabled && !opaque) {
|
||||
setOpaque(true);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -77,17 +90,18 @@ public abstract class ProjectViewTree extends DnDAwareTree {
|
||||
final Object element = ((AbstractTreeNode)object).getValue();
|
||||
if (element instanceof PsiElement) {
|
||||
final PsiElement psi = (PsiElement)element;
|
||||
final Project project = psi.getProject();
|
||||
final PsiFile file = psi.getContainingFile();
|
||||
if (!psi.isValid()) return null;
|
||||
|
||||
final VirtualFile file = PsiUtilCore.getVirtualFile(psi);
|
||||
|
||||
if (file != null) {
|
||||
color = FileColorManager.getInstance(project).getFileColor(file);
|
||||
color = FileColorManager.getInstance(getProject()).getFileColor(file);
|
||||
} else if (psi instanceof PsiDirectory) {
|
||||
color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
|
||||
color = FileColorManager.getInstance(getProject()).getFileColor(((PsiDirectory)psi).getVirtualFile());
|
||||
} else if (psi instanceof PsiDirectoryContainer) {
|
||||
final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
|
||||
for (PsiDirectory dir : dirs) {
|
||||
Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
|
||||
Color c = FileColorManager.getInstance(getProject()).getFileColor(dir.getVirtualFile());
|
||||
if (c != null && color == null) {
|
||||
color = c;
|
||||
} else if (c != null && color != null) {
|
||||
|
||||
@@ -503,7 +503,6 @@ public class VfsUtil extends VfsUtilCore {
|
||||
while (src.getParent() != commonAncestor) {
|
||||
buffer.append("..").append(separatorChar);
|
||||
src = src.getParent();
|
||||
assert src != null;
|
||||
}
|
||||
}
|
||||
buffer.append(getRelativePath(dst, commonAncestor, separatorChar));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -256,6 +256,11 @@ public class SimpleTree extends Tree implements CellEditorListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFileColorsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean paintNodes() {
|
||||
return true;
|
||||
|
||||
@@ -283,6 +283,9 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
}
|
||||
|
||||
if (isFileColorsEnabled()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
paintFileColorGutter(g);
|
||||
}
|
||||
|
||||
|
||||
@@ -967,4 +967,24 @@ public final class TreeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static int indexedBinarySearch(@NotNull TreeNode parent, @NotNull TreeNode key, Comparator comparator) {
|
||||
int low = 0;
|
||||
int high = parent.getChildCount() - 1;
|
||||
|
||||
while (low <= high) {
|
||||
int mid = (low + high) / 2;
|
||||
TreeNode treeNode = parent.getChildAt(mid);
|
||||
int cmp = comparator.compare(treeNode, key);
|
||||
if (cmp < 0) {
|
||||
low = mid + 1;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
high = mid - 1;
|
||||
}
|
||||
else {
|
||||
return mid; // key found
|
||||
}
|
||||
}
|
||||
return -(low + 1); // key not found
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ShowRecentFilesAction extends DumbAwareAction {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
if (project != null) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.recent.files");
|
||||
Switcher.createAndShowSwitcher(project, IdeBundle.message("title.popup.recent.files"), true);
|
||||
Switcher.createAndShowSwitcher(project, IdeBundle.message("title.popup.recent.files"), true).goForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
SwitcherPanel(Project project, String title, boolean pinned) {
|
||||
super(new BorderLayout(0, 0));
|
||||
this.project = project;
|
||||
MAX_FILES_IN_SWITCHER = pinned ? UISettings.getInstance().RECENT_FILES_LIMIT + UISettings.getInstance().EDITOR_TAB_LIMIT : 30;
|
||||
MAX_FILES_IN_SWITCHER = pinned ? UISettings.getInstance().RECENT_FILES_LIMIT : 30;
|
||||
myPinned = pinned;
|
||||
mySpeedSearch = pinned ? new SwitcherSpeedSearch() : null;
|
||||
|
||||
@@ -297,8 +297,10 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(project);
|
||||
final ArrayList<FileInfo> filesData = new ArrayList<FileInfo>();
|
||||
final ArrayList<FileInfo> editors = new ArrayList<FileInfo>();
|
||||
for (Pair<VirtualFile, EditorWindow> pair : editorManager.getSelectionHistory()) {
|
||||
editors.add(new FileInfo(pair.first, pair.second));
|
||||
if (!pinned) {
|
||||
for (Pair<VirtualFile, EditorWindow> pair : editorManager.getSelectionHistory()) {
|
||||
editors.add(new FileInfo(pair.first, pair.second));
|
||||
}
|
||||
}
|
||||
if (editors.size() < 2 || isPinnedMode()) {
|
||||
if (isPinnedMode() && editors.size() > 1) {
|
||||
@@ -306,7 +308,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
}
|
||||
final VirtualFile[] recentFiles = ArrayUtil.reverseArray(EditorHistoryManager.getInstance(project).getFiles());
|
||||
final int maxFiles = Math.max(editors.size(), recentFiles.length);
|
||||
final int len = isPinnedMode() ? maxFiles : Math.min(toolWindows.getModel().getSize(), maxFiles);
|
||||
final int len = isPinnedMode() ? recentFiles.length : Math.min(toolWindows.getModel().getSize(), maxFiles);
|
||||
boolean firstRecentMarked = false;
|
||||
for (int i = 0; i < len; i++) {
|
||||
final FileInfo info = new FileInfo(recentFiles[i], null);
|
||||
|
||||
@@ -430,6 +430,9 @@
|
||||
<extensionPoint name="testCreator"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint"/>
|
||||
|
||||
<extensionPoint name="constructorBodyGenerator"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint"/>
|
||||
|
||||
<extensionPoint name="testGenerator"
|
||||
beanClass="com.intellij.lang.LanguageExtensionPoint"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -110,9 +110,16 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
|
||||
@Override
|
||||
public boolean isFileColorsEnabled() {
|
||||
return Registry.is("file.colors.in.commit.dialog")
|
||||
&& FileColorManager.getInstance(project).isEnabled()
|
||||
&& FileColorManager.getInstance(project).isEnabledForProjectView();
|
||||
final boolean enabled = Registry.is("file.colors.in.commit.dialog")
|
||||
&& FileColorManager.getInstance(project).isEnabled()
|
||||
&& FileColorManager.getInstance(project).isEnabledForProjectView();
|
||||
final boolean opaque = isOpaque();
|
||||
if (enabled && opaque) {
|
||||
setOpaque(false);
|
||||
} else if (!enabled && !opaque) {
|
||||
setOpaque(true);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -784,6 +791,30 @@ public abstract class ChangesTreeList<T> extends JPanel {
|
||||
append(part.getFirst(), part.getSecond().derive(SimpleTextAttributes.GRAYED_ATTRIBUTES));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
final Component component = super.getListCellRendererComponent(list, value, index, selected, hasFocus);
|
||||
final FileColorManager colorManager = FileColorManager.getInstance(myProject);
|
||||
if (!selected) {
|
||||
if (Registry.is("file.colors.in.commit.dialog") && colorManager.isEnabled() && colorManager.isEnabledForProjectView()) {
|
||||
if (value instanceof Change) {
|
||||
final VirtualFile file = ((Change)value).getVirtualFile();
|
||||
if (file != null) {
|
||||
final Color color = colorManager.getFileColor(file);
|
||||
if (color != null) {
|
||||
component.setBackground(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}
|
||||
};
|
||||
|
||||
myCheckbox.setBackground(null);
|
||||
|
||||
+5
@@ -17,6 +17,7 @@ package com.intellij.android.designer.componentTree;
|
||||
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.model.IComponentDecorator;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.palette.Item;
|
||||
@@ -76,6 +77,10 @@ public final class AndroidTreeDecorator extends TreeComponentDecorator {
|
||||
|
||||
renderer.append(fullTitle.toString());
|
||||
renderer.setIcon(metaModel.getIcon());
|
||||
|
||||
if (component instanceof IComponentDecorator) {
|
||||
((IComponentDecorator)component).decorateTree(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+153
-19
@@ -24,6 +24,8 @@ import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
@@ -36,51 +38,183 @@ public class GridLayoutOperation extends GridOperation {
|
||||
public void execute() throws Exception {
|
||||
GridInfo gridInfo = getGridInfo();
|
||||
|
||||
RadViewComponent container = (RadViewComponent)myContainer;
|
||||
RadGridLayoutComponent container = (RadGridLayoutComponent)myContainer;
|
||||
RadComponent[][] components = container.getGridComponents(false);
|
||||
RadComponent editComponent = myComponents.get(0);
|
||||
RadViewComponent nextComponent = getNextComponent(components, myRow, myColumn);
|
||||
|
||||
if (myInsertType == GridInsertType.in_cell) {
|
||||
if (myRow <= gridInfo.lastRow && myColumn <= gridInfo.lastColumn) {
|
||||
RadComponent insertBefore = getNextComponent(myRow, myColumn);
|
||||
|
||||
if (editComponent != insertBefore) {
|
||||
execute(myContext, container, myComponents, (RadViewComponent)insertBefore);
|
||||
if (myContext.isMove()) {
|
||||
Rectangle cellInfo = RadGridLayoutComponent.getCellInfo(editComponent);
|
||||
components[cellInfo.y][cellInfo.x] = null;
|
||||
components[myRow][myColumn] = editComponent;
|
||||
}
|
||||
else {
|
||||
execute(myContext, container, myComponents, nextComponent);
|
||||
RadGridLayoutComponent.setCellIndex(editComponent, myRow, myColumn);
|
||||
return;
|
||||
}
|
||||
RadGridLayoutComponent.setCellIndex(editComponent, myRow, myColumn);
|
||||
}
|
||||
else {
|
||||
execute(myContext, container, myComponents, null);
|
||||
RadGridLayoutComponent.setCellIndex(editComponent, myRow, myColumn);
|
||||
RadGridLayoutComponent.setGridSize(container,
|
||||
Math.max(myRow + 1, gridInfo.lastRow + 1),
|
||||
Math.max(myColumn + 1, gridInfo.lastColumn + 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (myInsertType == GridInsertType.before_h_cell || myInsertType == GridInsertType.after_h_cell) {
|
||||
insertComponent(components, nextComponent, true, myInsertType == GridInsertType.after_h_cell, false, false);
|
||||
}
|
||||
else if (myInsertType == GridInsertType.before_v_cell || myInsertType == GridInsertType.after_v_cell) {
|
||||
insertComponent(components, nextComponent, false, false, true, myInsertType == GridInsertType.after_v_cell);
|
||||
}
|
||||
else {
|
||||
insertComponent(components, nextComponent,
|
||||
true, myInsertType == GridInsertType.corner_bottom_left || myInsertType == GridInsertType.corner_bottom_right,
|
||||
true, myInsertType == GridInsertType.corner_top_right || myInsertType == GridInsertType.corner_bottom_right);
|
||||
}
|
||||
|
||||
validateLayoutParams(components);
|
||||
|
||||
if (myContext.isMove()) {
|
||||
RadGridLayoutComponent.clearCellSpans(editComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLayoutParams(RadComponent[][] components) throws Exception {
|
||||
// TODO: Auto-generated method stub
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RadComponent getNextComponent(int row, int column) {
|
||||
GridInfo gridInfo = getGridInfo();
|
||||
RadComponent[][] components = gridInfo.components;
|
||||
private RadComponent[][] insertComponent(RadComponent[][] components,
|
||||
RadViewComponent nextComponent,
|
||||
boolean insertRow,
|
||||
boolean afterRow,
|
||||
boolean insertColumn,
|
||||
boolean afterColumn) throws Exception {
|
||||
int row = myRow;
|
||||
if (insertRow && afterRow) {
|
||||
row++;
|
||||
}
|
||||
|
||||
int column = myColumn;
|
||||
if (insertColumn && afterColumn) {
|
||||
column++;
|
||||
}
|
||||
|
||||
if (insertRow) {
|
||||
shiftRowSpan(row);
|
||||
}
|
||||
if (insertColumn) {
|
||||
shiftColumnSpan(column);
|
||||
}
|
||||
if (insertRow) {
|
||||
components = insertRow(components, row);
|
||||
}
|
||||
if (insertColumn) {
|
||||
insertColumn(components, column);
|
||||
}
|
||||
|
||||
RadGridLayoutComponent container = (RadGridLayoutComponent)myContainer;
|
||||
RadComponent editComponent = myComponents.get(0);
|
||||
|
||||
components[row][column] = editComponent;
|
||||
|
||||
if (myContext.isMove()) {
|
||||
Rectangle cellInfo = RadGridLayoutComponent.getCellInfo(editComponent);
|
||||
components[cellInfo.y][cellInfo.x] = null;
|
||||
}
|
||||
|
||||
if (editComponent != nextComponent) {
|
||||
execute(myContext, container, myComponents, nextComponent);
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
private void shiftRowSpan(int row) {
|
||||
GridInfo gridInfo = getGridInfo();
|
||||
if (row == gridInfo.lastRow) {
|
||||
return;
|
||||
}
|
||||
|
||||
RadComponent[] rowComponents = gridInfo.components[row];
|
||||
RadComponent[] rowComponents1 = gridInfo.components[row + 1];
|
||||
|
||||
for (int i = 0; i < rowComponents.length; i++) {
|
||||
RadComponent cellComponent = rowComponents[i];
|
||||
if (cellComponent != null) {
|
||||
if (cellComponent == rowComponents1[i]) {
|
||||
RadGridLayoutComponent.setSpan(cellComponent, RadGridLayoutComponent.getSpan(cellComponent, true) + 1, true);
|
||||
}
|
||||
|
||||
while (i + 1 < rowComponents.length && cellComponent == rowComponents[i + 1]) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static RadComponent[][] insertRow(RadComponent[][] components, int row) {
|
||||
RadComponent[][] newComponents = new RadComponent[components.length + 1][];
|
||||
|
||||
System.arraycopy(components, 0, newComponents, 0, row);
|
||||
System.arraycopy(components, row, newComponents, row + 1, components.length - row);
|
||||
|
||||
newComponents[row] = new RadComponent[components[0].length];
|
||||
|
||||
return newComponents;
|
||||
}
|
||||
|
||||
private void shiftColumnSpan(int column) {
|
||||
GridInfo gridInfo = getGridInfo();
|
||||
if (column == gridInfo.lastColumn) {
|
||||
return;
|
||||
}
|
||||
|
||||
RadComponent[][] components = gridInfo.components;
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
RadComponent[] rowComponents = components[i];
|
||||
RadComponent cellComponent = rowComponents[column];
|
||||
|
||||
if (cellComponent != null) {
|
||||
if (cellComponent == rowComponents[column + 1]) {
|
||||
RadGridLayoutComponent.setSpan(cellComponent, RadGridLayoutComponent.getSpan(cellComponent, false) + 1, false);
|
||||
}
|
||||
|
||||
while (i + 1 < components.length && cellComponent == components[i + 1][column]) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void insertColumn(RadComponent[][] components, int column) {
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
RadComponent[] rowComponents = components[i];
|
||||
RadComponent[] newRowComponents = new RadComponent[rowComponents.length + 1];
|
||||
|
||||
System.arraycopy(rowComponents, 0, newRowComponents, 0, column);
|
||||
System.arraycopy(rowComponents, column, newRowComponents, column + 1, rowComponents.length - column);
|
||||
|
||||
components[i] = newRowComponents;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static RadViewComponent getNextComponent(RadComponent[][] components, int row, int column) {
|
||||
RadComponent[] rowComponents = components[row];
|
||||
|
||||
for (int i = column + 1; i < rowComponents.length; i++) {
|
||||
RadComponent component = rowComponents[i];
|
||||
if (component != null) {
|
||||
return component;
|
||||
return (RadViewComponent)component;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = row + 1; i < components.length; i++) {
|
||||
rowComponents = components[i];
|
||||
|
||||
for (int j = 0; i < rowComponents.length; j++) {
|
||||
RadComponent component = rowComponents[j];
|
||||
for (RadComponent component : components[i]) {
|
||||
if (component != null) {
|
||||
return component;
|
||||
return (RadViewComponent)component;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ public class GridInfo {
|
||||
|
||||
public int[] hLines = ArrayUtil.EMPTY_INT_ARRAY;
|
||||
public int[] vLines = ArrayUtil.EMPTY_INT_ARRAY;
|
||||
|
||||
public boolean[] emptyColumns = ArrayUtil.EMPTY_BOOLEAN_ARRAY;
|
||||
public boolean[] emptyRows = ArrayUtil.EMPTY_BOOLEAN_ARRAY;
|
||||
|
||||
public RadComponent[][] components;
|
||||
public int lastRow = -1;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import com.intellij.android.designer.model.grid.RadCaptionColumn;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RadCaptionGridColumn extends RadCaptionColumn<RadGridLayoutComponent> {
|
||||
public RadCaptionGridColumn(RadGridLayoutComponent container, int index, int offset, int width) {
|
||||
super(container, index, offset, width, false);
|
||||
public RadCaptionGridColumn(RadGridLayoutComponent container, int index, int offset, int width, boolean empty) {
|
||||
super(container, index, offset, width, empty);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -21,7 +21,7 @@ import com.intellij.android.designer.model.grid.RadCaptionRow;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RadCaptionGridRow extends RadCaptionRow<RadGridLayoutComponent> {
|
||||
public RadCaptionGridRow(RadGridLayoutComponent container, int index, int offset, int width) {
|
||||
super(container, index, offset, width, false);
|
||||
public RadCaptionGridRow(RadGridLayoutComponent container, int index, int offset, int width, boolean empty) {
|
||||
super(container, index, offset, width, empty);
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -159,20 +159,26 @@ public class RadGridLayout extends RadViewLayoutWithData implements ILayoutDecor
|
||||
|
||||
if (horizontal) {
|
||||
int[] lines = gridInfo.vLines;
|
||||
boolean[] emptyColumns = gridInfo.emptyColumns;
|
||||
|
||||
for (int i = 0; i < lines.length - 1; i++) {
|
||||
components.add(new RadCaptionGridColumn(container,
|
||||
i,
|
||||
lines[i],
|
||||
lines[i + 1] - lines[i]));
|
||||
lines[i + 1] - lines[i],
|
||||
emptyColumns[i]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
int[] lines = gridInfo.hLines;
|
||||
boolean[] emptyRows = gridInfo.emptyRows;
|
||||
|
||||
for (int i = 0; i < lines.length - 1; i++) {
|
||||
components.add(new RadCaptionGridRow(container,
|
||||
i,
|
||||
lines[i],
|
||||
lines[i + 1] - lines[i]));
|
||||
lines[i + 1] - lines[i],
|
||||
emptyRows[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+86
-12
@@ -21,21 +21,42 @@ import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.RadViewContainer;
|
||||
import com.intellij.android.designer.model.grid.GridInfo;
|
||||
import com.intellij.android.designer.model.grid.IGridProvider;
|
||||
import com.intellij.designer.model.IComponentDecorator;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RadGridLayoutComponent extends RadViewContainer implements IGridProvider {
|
||||
public class RadGridLayoutComponent extends RadViewContainer implements IComponentDecorator, IGridProvider {
|
||||
private GridInfo myGridInfo;
|
||||
private GridInfo myVirtualGridInfo;
|
||||
|
||||
@Override
|
||||
public void decorateTree(ColoredTreeCellRenderer renderer) {
|
||||
XmlTag tag = getTag();
|
||||
StringBuilder value = new StringBuilder(" (");
|
||||
|
||||
String rowCount = tag.getAttributeValue("android:rowCount");
|
||||
value.append(StringUtil.isEmpty(rowCount) ? "?" : rowCount).append(", ");
|
||||
|
||||
String columnCount = tag.getAttributeValue("android:columnCount");
|
||||
value.append(StringUtil.isEmpty(columnCount) ? "?" : columnCount).append(", ");
|
||||
|
||||
String orientation = tag.getAttributeValue("android:orientation");
|
||||
value.append(StringUtil.isEmpty(orientation) ? "horizontal" : orientation);
|
||||
|
||||
renderer.append(value.append(")").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewInfo(ViewInfo viewInfo) {
|
||||
super.setViewInfo(viewInfo);
|
||||
@@ -68,12 +89,14 @@ public class RadGridLayoutComponent extends RadViewContainer implements IGridPro
|
||||
field_locations.setAccessible(true);
|
||||
|
||||
myGridInfo.vLines = (int[])field_locations.get(horizontalAxis);
|
||||
myGridInfo.emptyColumns = configureEmptyLines(myGridInfo.vLines);
|
||||
|
||||
Field field_verticalAxis = viewClass.getDeclaredField("verticalAxis");
|
||||
field_verticalAxis.setAccessible(true);
|
||||
Object verticalAxis = field_verticalAxis.get(viewObject);
|
||||
|
||||
myGridInfo.hLines = (int[])field_locations.get(verticalAxis);
|
||||
myGridInfo.emptyRows = configureEmptyLines(myGridInfo.hLines);
|
||||
|
||||
Rectangle bounds = getBounds();
|
||||
|
||||
@@ -96,6 +119,37 @@ public class RadGridLayoutComponent extends RadViewContainer implements IGridPro
|
||||
return myGridInfo;
|
||||
}
|
||||
|
||||
private static final int EMPTY_CELL = 5;
|
||||
|
||||
private static boolean[] configureEmptyLines(int[] lines) {
|
||||
boolean[] empty = new boolean[lines.length - 1];
|
||||
int[] originalLines = Arrays.copyOf(lines, lines.length);
|
||||
|
||||
for (int i = 0; i < empty.length; i++) {
|
||||
int line_i = originalLines[i];
|
||||
int length = originalLines[i + 1] - line_i;
|
||||
empty[i] = length == 0;
|
||||
|
||||
if (length == 0) {
|
||||
int startMove = i + 1;
|
||||
while (startMove < lines.length && line_i == lines[startMove]) {
|
||||
startMove++;
|
||||
}
|
||||
|
||||
for (int j = i + 1; j < lines.length; j++) {
|
||||
lines[j] += EMPTY_CELL;
|
||||
}
|
||||
for (int j = startMove; j < lines.length; j++) {
|
||||
if (lines[j - 1] < lines[j] - 2 * EMPTY_CELL) {
|
||||
lines[j] -= 2 * EMPTY_CELL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridInfo getVirtualGridInfo() {
|
||||
if (myVirtualGridInfo == null) {
|
||||
@@ -174,17 +228,6 @@ public class RadGridLayoutComponent extends RadViewContainer implements IGridPro
|
||||
return cellInfo;
|
||||
}
|
||||
|
||||
public static void setGridSize(final RadViewComponent container, final int rowCount, final int columnCount) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
XmlTag tag = container.getTag();
|
||||
tag.setAttribute("android:rowCount", Integer.toString(rowCount));
|
||||
tag.setAttribute("android:columnCount", Integer.toString(columnCount));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setCellIndex(final RadComponent component, final int row, final int column) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
@@ -197,4 +240,35 @@ public class RadGridLayoutComponent extends RadViewContainer implements IGridPro
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getSpan(RadComponent component, boolean row) {
|
||||
try {
|
||||
String span = ((RadViewComponent)component).getTag().getAttributeValue(row ? "android:layout_rowSpan" : "android:layout_columnSpan");
|
||||
return Integer.parseInt(span);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSpan(final RadComponent component, final int span, final boolean row) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
XmlTag tag = ((RadViewComponent)component).getTag();
|
||||
tag.setAttribute(row ? "android:layout_rowSpan" : "android:layout_columnSpan", Integer.toString(span));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void clearCellSpans(final RadComponent component) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
XmlTag tag = ((RadViewComponent)component).getTag();
|
||||
ModelParser.deleteAttribute(tag, "android:layout_rowSpan");
|
||||
ModelParser.deleteAttribute(tag, "android:layout_columnSpan");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler {
|
||||
if (facet != null) {
|
||||
AndroidFacetConfiguration configuration = facet.getConfiguration();
|
||||
if (!isToCompileModule(module, configuration) ||
|
||||
(facet.getConfiguration().LIBRARY_PROJECT && hasBadCircularDependencies(facet))) {
|
||||
AndroidCompileUtil.isLibraryWithBadCircularDependency(facet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -274,34 +274,6 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler {
|
||||
}
|
||||
return items.toArray(new GenerationItem[items.size()]);
|
||||
}
|
||||
|
||||
// support for lib<->lib and app<->lib circular dependencies
|
||||
// see IDEA-79737 for details
|
||||
private static boolean hasBadCircularDependencies(@NotNull AndroidFacet facet) {
|
||||
final List<AndroidFacet> dependencies = AndroidUtils.getAllAndroidDependencies(facet.getModule(), false);
|
||||
|
||||
final Manifest manifest = facet.getManifest();
|
||||
if (manifest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String aPackage = manifest.getPackage().getValue();
|
||||
if (aPackage == null || aPackage.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AndroidFacet depFacet : dependencies) {
|
||||
final List<AndroidFacet> depDependencies = AndroidUtils.getAllAndroidDependencies(depFacet.getModule(), true);
|
||||
|
||||
if (depDependencies.contains(facet) &&
|
||||
dependencies.contains(depFacet) &&
|
||||
(depFacet.getModule().getName().compareTo(facet.getModule().getName()) < 0 ||
|
||||
!depFacet.getConfiguration().LIBRARY_PROJECT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyValidityState extends ResourceNamesValidityState {
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class AndroidBuildConfigGeneratingCompiler implements SourceGeneratingCom
|
||||
|
||||
for (Module module : ModuleManager.getInstance(context.getProject()).getModules()) {
|
||||
final AndroidFacet facet = AndroidFacet.getInstance(module);
|
||||
if (facet == null) {
|
||||
if (facet == null || AndroidCompileUtil.isLibraryWithBadCircularDependency(facet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -918,4 +918,36 @@ public class AndroidCompileUtil {
|
||||
|
||||
return ArrayUtil.toStringArray(result);
|
||||
}
|
||||
|
||||
// support for lib<->lib and app<->lib circular dependencies
|
||||
// see IDEA-79737 for details
|
||||
public static boolean isLibraryWithBadCircularDependency(@NotNull AndroidFacet facet) {
|
||||
if (!facet.getConfiguration().LIBRARY_PROJECT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<AndroidFacet> dependencies = AndroidUtils.getAllAndroidDependencies(facet.getModule(), false);
|
||||
|
||||
final Manifest manifest = facet.getManifest();
|
||||
if (manifest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String aPackage = manifest.getPackage().getValue();
|
||||
if (aPackage == null || aPackage.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AndroidFacet depFacet : dependencies) {
|
||||
final List<AndroidFacet> depDependencies = AndroidUtils.getAllAndroidDependencies(depFacet.getModule(), true);
|
||||
|
||||
if (depDependencies.contains(facet) &&
|
||||
dependencies.contains(depFacet) &&
|
||||
(depFacet.getModule().getName().compareTo(facet.getModule().getName()) < 0 ||
|
||||
!depFacet.getConfiguration().LIBRARY_PROJECT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -21,7 +21,8 @@ import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.android.fileTypes.AndroidRenderscriptFileType;
|
||||
import org.jetbrains.android.sdk.AndroidPlatform;
|
||||
import org.jetbrains.android.util.*;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -182,6 +183,8 @@ public class AndroidRenderscriptCompiler implements SourceGeneratingCompiler {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
|
||||
for (final VirtualFile sourceFile : genItem.myFiles) {
|
||||
final String depFolderOsPath = getDependencyFolder(context.getProject(), sourceFile, outputRootDirectory);
|
||||
|
||||
@@ -201,8 +204,8 @@ public class AndroidRenderscriptCompiler implements SourceGeneratingCompiler {
|
||||
}
|
||||
});
|
||||
|
||||
if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) {
|
||||
results.add(genItem);
|
||||
if (messages.get(CompilerMessageCategory.ERROR).size() > 0) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
catch (final IOException e) {
|
||||
@@ -212,8 +215,13 @@ public class AndroidRenderscriptCompiler implements SourceGeneratingCompiler {
|
||||
context.addMessage(CompilerMessageCategory.ERROR, e.getMessage(), sourceFile.getUrl(), -1, -1);
|
||||
}
|
||||
});
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
results.add(genItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
outputRootDirectory.refresh(false, true);
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
<testFramework implementation="org.jetbrains.plugins.groovy.testIntegration.GroovyTestFramework"/>
|
||||
<testCreator language="Groovy" implementationClass="com.intellij.testIntegration.JavaTestCreator"/>
|
||||
<testGenerator language="Groovy" implementationClass="org.jetbrains.plugins.groovy.testIntegration.GroovyTestGenerator"/>
|
||||
<constructorBodyGenerator language="Groovy" implementationClass="org.jetbrains.plugins.groovy.annotator.intentions.dynamic.GrConstructorBodyGenerator"/>
|
||||
<editorNotificationProvider implementation="org.jetbrains.plugins.groovy.annotator.ConfigureGroovyLibraryNotificationProvider"/>
|
||||
<refactoring.introduceParameterMethodUsagesProcessor implementation="org.jetbrains.plugins.groovy.refactoring.introduce.parameter.java2groovy.GroovyIntroduceParameterMethodUsagesProcessor"/>
|
||||
<refactoring.changeSignatureUsageProcessor implementation="org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureUsageProcessor" id="groovyProcessor" order="before javaProcessor"/>
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodBodyFix;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.CreateConstructorMatchingSuperFix;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.OrderEntryFix;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
@@ -429,7 +430,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (constructors.length == 0) {
|
||||
if (!hasImplicitDefConstructor && (defConstructor == null || !PsiUtil.isAccessible(typeDefinition, defConstructor))) {
|
||||
final TextRange range = getClassHeaderTextRange(typeDefinition);
|
||||
holder.createErrorAnnotation(range, GroovyBundle.message("there.is.no.default.constructor.available.in.class.0", qName));
|
||||
holder.createErrorAnnotation(range, GroovyBundle.message("there.is.no.default.constructor.available.in.class.0", qName)).registerFix(new CreateConstructorMatchingSuperFix(typeDefinition));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.groovy.annotator.intentions.dynamic;
|
||||
|
||||
import com.intellij.codeInsight.generation.ConstructorBodyGenerator;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GrConstructorBodyGenerator implements ConstructorBodyGenerator {
|
||||
@Override
|
||||
public void generateFieldInitialization(@NotNull StringBuilder buffer,
|
||||
@NotNull PsiField[] fields,
|
||||
@NotNull PsiParameter[] parameters) {
|
||||
for (int i = 0, length = fields.length; i < length; i++) {
|
||||
String fieldName = fields[i].getName();
|
||||
String paramName = parameters[i].getName();
|
||||
if (fieldName.equals(paramName)) {
|
||||
buffer.append("this.");
|
||||
}
|
||||
buffer.append(fieldName);
|
||||
buffer.append("=");
|
||||
buffer.append(paramName);
|
||||
buffer.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSuperCallIfNeeded(@NotNull StringBuilder buffer, @NotNull PsiParameter[] parameters) {
|
||||
if (parameters.length > 0) {
|
||||
buffer.append("super(");
|
||||
for (int j = 0; j < parameters.length; j++) {
|
||||
PsiParameter param = parameters[j];
|
||||
buffer.append(param.getName());
|
||||
if (j < parameters.length - 1) buffer.append(",");
|
||||
}
|
||||
buffer.append(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuilder start(StringBuilder buffer, @NotNull String name, @NotNull PsiParameter[] parameters) {
|
||||
buffer.append("public ").append(name).append("(");
|
||||
for (PsiParameter parameter : parameters) {
|
||||
buffer.append(parameter.getType().getPresentableText()).append(' ').append(parameter.getName()).append(',');
|
||||
}
|
||||
if (parameters.length > 0) {
|
||||
buffer.delete(buffer.length() - 1, buffer.length());
|
||||
}
|
||||
buffer.append("){\n");
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(StringBuilder buffer) {
|
||||
buffer.append('}');
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -314,7 +314,7 @@ public class ConvertParameterToMapEntryIntention extends Intention {
|
||||
if (createNewFirstParam) {
|
||||
try {
|
||||
final GrParameter newParam = factory.createParameter(mapName, specifyMapType ? MAP_TYPE_TEXT : "", null);
|
||||
list.addParameterToHead(newParam);
|
||||
list.addAfter(newParam, null);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
|
||||
-4
@@ -28,9 +28,5 @@ public interface GrParameterList extends GroovyPsiElement, PsiParameterList {
|
||||
@NotNull
|
||||
GrParameter[] getParameters();
|
||||
|
||||
GrParameter addParameterToEnd(GrParameter parameter);
|
||||
|
||||
void addParameterToHead(GrParameter parameter);
|
||||
|
||||
int getParameterNumber(GrParameter parameter);
|
||||
}
|
||||
|
||||
+4
@@ -151,4 +151,8 @@ public class GrClassReferenceType extends PsiClassType {
|
||||
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
|
||||
return new GrClassReferenceType(myReferenceElement,languageLevel);
|
||||
}
|
||||
|
||||
public GrReferenceElement getReference() {
|
||||
return myReferenceElement;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-5
@@ -154,6 +154,21 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
return (GrExpression) topStatements[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrCodeReferenceElement createReferenceElementByType(PsiClassType type) {
|
||||
if (type instanceof GrClassReferenceType) {
|
||||
GrReferenceElement reference = ((GrClassReferenceType)type).getReference();
|
||||
if (reference instanceof GrCodeReferenceElement) {
|
||||
return (GrCodeReferenceElement)reference;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
|
||||
final PsiClass refClass = resolveResult.getElement();
|
||||
assert refClass != null : type;
|
||||
return createCodeReferenceElementFromText(type.getPresentableText());
|
||||
}
|
||||
|
||||
public GrVariableDeclaration createVariableDeclaration(@Nullable String[] modifiers,
|
||||
@Nullable GrExpression initializer,
|
||||
@Nullable PsiType type,
|
||||
@@ -397,12 +412,19 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
return createConstructorFromText(constructorName, text, context);
|
||||
}
|
||||
|
||||
public GrMethod createConstructorFromText(String constructorName, String text, @Nullable PsiElement context) {
|
||||
GroovyFileImpl file = createDummyFile("class " + constructorName + "{" + text + "}");
|
||||
public GrMethod createConstructorFromText(String constructorName, String constructorText, @Nullable PsiElement context) {
|
||||
GroovyFileImpl file = createDummyFile("class " + constructorName + "{" + constructorText + "}");
|
||||
file.setContext(context);
|
||||
GrTopLevelDefinition definition = file.getTopLevelDefinitions()[0];
|
||||
assert definition != null && definition instanceof GrClassDefinition;
|
||||
return ((GrClassDefinition) definition).getGroovyMethods()[0];
|
||||
|
||||
if (!( definition != null && definition instanceof GrClassDefinition)) {
|
||||
throw new IncorrectOperationException("constructorName: " + constructorName + ", text: " + constructorText);
|
||||
}
|
||||
GrMethod[] methods = ((GrClassDefinition)definition).getGroovyMethods();
|
||||
if (methods.length != 1) {
|
||||
throw new IncorrectOperationException("constructorName: " + constructorName + ", text: " + constructorText);
|
||||
}
|
||||
return methods[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -842,7 +864,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod createConstructor() {
|
||||
return createConstructorFromText("Foo", "", null);
|
||||
return createConstructorFromText("Foo", "Foo(){}", null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -524,7 +524,6 @@ public class PsiImplUtil {
|
||||
return AstBufferUtil.getTextSkippingWhitespaceComments(node);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiCodeBlock getOrCreatePsiCodeBlock(GrOpenBlock block) {
|
||||
if (block == null) return null;
|
||||
|
||||
|
||||
+22
@@ -18,13 +18,17 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
/**
|
||||
* @author: Dmitry.Krasilschikov
|
||||
@@ -63,4 +67,22 @@ public class GrThrowsClauseImpl extends GroovyPsiElementImpl implements GrThrows
|
||||
public Role getRole() {
|
||||
return Role.THROWS_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
if (findChildByClass(GrCodeReferenceElement.class) == null) {
|
||||
getNode().addLeaf(GroovyTokenTypes.kTHROWS, "throws", null);
|
||||
}
|
||||
else {
|
||||
PsiElement lastChild = getLastChild();
|
||||
lastChild = PsiUtil.skipWhitespaces(lastChild, false);
|
||||
if (!lastChild.getNode().getElementType().equals(GroovyTokenTypes.mCOMMA)) {
|
||||
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -194,10 +194,10 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock
|
||||
parameterList.delete();
|
||||
ASTNode next = newParamList.getNode().getTreeNext();
|
||||
getNode().addLeaf(GroovyTokenTypes.mCLOSABLE_BLOCK_OP, "->", next);
|
||||
return newParamList.addParameterToEnd(parameter);
|
||||
return (GrParameter)newParamList.add(parameter);
|
||||
}
|
||||
|
||||
return parameterList.addParameterToEnd(parameter);
|
||||
return (GrParameter)parameterList.add(parameter);
|
||||
}
|
||||
|
||||
public boolean hasParametersSection() {
|
||||
|
||||
+24
-26
@@ -21,10 +21,8 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.stubs.EmptyStub;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
@@ -75,28 +73,6 @@ public class GrParameterListImpl extends GrStubElementBase<EmptyStub> implements
|
||||
return getParameters().length;
|
||||
}
|
||||
|
||||
public GrParameter addParameterToEnd(GrParameter parameter) {
|
||||
GrParameter[] params = getParameters();
|
||||
if (params.length == 0) {
|
||||
return (GrParameter)add(parameter);
|
||||
}
|
||||
else {
|
||||
GrParameter last = params[params.length - 1];
|
||||
return (GrParameter)addAfter(parameter, last);
|
||||
}
|
||||
}
|
||||
|
||||
public void addParameterToHead(GrParameter parameter) {
|
||||
GrParameter[] params = getParameters();
|
||||
if (params.length == 0) {
|
||||
add(parameter);
|
||||
}
|
||||
else {
|
||||
GrParameter first = params[0];
|
||||
addBefore(parameter, first);
|
||||
}
|
||||
}
|
||||
|
||||
public int getParameterNumber(final GrParameter parameter) {
|
||||
GrParameter[] parameters = getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
@@ -108,7 +84,7 @@ public class GrParameterListImpl extends GrStubElementBase<EmptyStub> implements
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public PsiElement addAfter(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
|
||||
GrParameter[] params = getParameters();
|
||||
|
||||
@@ -150,6 +126,28 @@ public class GrParameterListImpl extends GrStubElementBase<EmptyStub> implements
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
|
||||
GrParameter[] params = getParameters();
|
||||
|
||||
ASTNode result = super.addInternal(first, last, anchor, before);
|
||||
if (first == last && first.getPsi() instanceof GrParameter && params.length > 0) {
|
||||
if (before.booleanValue() && anchor != null) {
|
||||
getNode().addLeaf(mCOMMA, ",", anchor);
|
||||
}
|
||||
else if (before.booleanValue() && anchor == null) {
|
||||
getNode().addLeaf(mCOMMA, ",", result);
|
||||
}
|
||||
else if (!before.booleanValue() && anchor != null) {
|
||||
getNode().addLeaf(mCOMMA, ",", result);
|
||||
}
|
||||
else if (!before.booleanValue() && anchor == null) {
|
||||
getNode().addLeaf(mCOMMA, ",", result.getTreeNext());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
|
||||
@@ -33,6 +35,11 @@ public class GrExtendsClauseImpl extends GrReferenceListImpl implements GrExtend
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IElementType getKeywordType() {
|
||||
return GroovyTokenTypes.kEXTENDS;
|
||||
}
|
||||
|
||||
public GrExtendsClauseImpl(final GrReferenceListStub stub) {
|
||||
super(stub, GroovyElementTypes.EXTENDS_CLAUSE);
|
||||
}
|
||||
|
||||
+7
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
|
||||
@@ -33,6 +35,11 @@ public class GrImplementsClauseImpl extends GrReferenceListImpl implements GrImp
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IElementType getKeywordType() {
|
||||
return GroovyTokenTypes.kIMPLEMENTS;
|
||||
}
|
||||
|
||||
public GrImplementsClauseImpl(final GrReferenceListStub stub) {
|
||||
super(stub, GroovyElementTypes.IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
+14
-9
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
@@ -88,16 +89,20 @@ public abstract class GrReferenceListImpl extends GrStubElementBase<GrReferenceL
|
||||
|
||||
@Override
|
||||
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof GrCodeReferenceElement && findChildByClass(GrCodeReferenceElement.class) != null) {
|
||||
PsiElement lastChild = getLastChild();
|
||||
lastChild = PsiUtil.skipWhitespaces(lastChild, false);
|
||||
if (!lastChild.getNode().getElementType().equals(GroovyTokenTypes.mCOMMA)) {
|
||||
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
if (findChildByType(getKeywordType()) == null) {
|
||||
getNode().addLeaf(getKeywordType(), getKeywordType().toString(), null);
|
||||
}
|
||||
else if (findChildByClass(GrCodeReferenceElement.class) != null) {
|
||||
PsiElement lastChild = getLastChild();
|
||||
lastChild = PsiUtil.skipWhitespaces(lastChild, false);
|
||||
if (!lastChild.getNode().getElementType().equals(GroovyTokenTypes.mCOMMA)) {
|
||||
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
|
||||
}
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
else {
|
||||
return super.add(element);
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
|
||||
protected abstract IElementType getKeywordType();
|
||||
}
|
||||
|
||||
-11
@@ -76,17 +76,6 @@ public class GrLightParameterListBuilder extends LightElement implements GrParam
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrParameter addParameterToEnd(GrParameter parameter) {
|
||||
return addParameter(parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addParameterToHead(GrParameter parameter) {
|
||||
myParameters.add(0, parameter);
|
||||
myCachedParameters = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterNumber(GrParameter parameter) {
|
||||
return getParameterIndex(parameter);
|
||||
|
||||
+16
@@ -15,20 +15,25 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
|
||||
/**
|
||||
* @author Medvedev Max
|
||||
*/
|
||||
public class GrSyntheticCodeBlock extends LightElement implements PsiCodeBlock {
|
||||
private static final Logger LOG = Logger.getInstance(GrSyntheticCodeBlock.class);
|
||||
private GrCodeBlock myCodeBlock;
|
||||
private static final Key<SoftReference<PsiJavaToken>> PSI_JAVA_TOKEN = Key.create("psi_java_token");
|
||||
|
||||
@@ -86,6 +91,17 @@ public class GrSyntheticCodeBlock extends LightElement implements PsiCodeBlock {
|
||||
return newToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
|
||||
if (newElement instanceof GrSyntheticCodeBlock) {
|
||||
GrSyntheticCodeBlock other = (GrSyntheticCodeBlock)newElement;
|
||||
PsiElement replaced = myCodeBlock.replace(other.myCodeBlock);
|
||||
LOG.assertTrue(replaced instanceof GrOpenBlock);
|
||||
return PsiImplUtil.getOrCreatePsiCodeBlock((GrOpenBlock)replaced);
|
||||
}
|
||||
return super.replace(newElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldChangeModificationCount(PsiElement place) {
|
||||
return false;
|
||||
|
||||
+3
-3
@@ -92,18 +92,18 @@ public class GrImportStatementImpl extends GroovyPsiElementImpl implements GrImp
|
||||
|
||||
final String refName = ref.getReferenceName();
|
||||
if (nameHint == null || name.equals(nameHint.getName(state))) {
|
||||
final PsiField field = clazz.findFieldByName(refName, false);
|
||||
final PsiField field = clazz.findFieldByName(refName, true);
|
||||
if (field != null && field.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (!processor.execute(field, state)) return false;
|
||||
}
|
||||
|
||||
for (PsiMethod method : clazz.findMethodsByName(refName, false)) {
|
||||
for (PsiMethod method : clazz.findMethodsByName(refName, true)) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (!processor.execute(method, state)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiClass innerClass = clazz.findInnerClassByName(refName, false);
|
||||
final PsiClass innerClass = clazz.findInnerClassByName(refName, true);
|
||||
if (innerClass != null && innerClass.hasModifierProperty(PsiModifier.STATIC) && !processor.execute(innerClass, state)) return false;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -474,17 +474,17 @@ public class GrCodeReferenceElementImpl extends GrReferenceElementImpl<GrCodeRef
|
||||
PsiResolveHelper helper = JavaPsiFacade.getInstance(clazz.getProject()).getResolveHelper();
|
||||
List<GroovyResolveResult> result = new ArrayList<GroovyResolveResult>();
|
||||
|
||||
final PsiField field = clazz.findFieldByName(refName, false);
|
||||
final PsiField field = clazz.findFieldByName(refName, true);
|
||||
if (field != null && field.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
result.add(new GroovyResolveResultImpl(field, helper.isAccessible(field, ref, null)));
|
||||
}
|
||||
|
||||
final PsiMethod[] methods = clazz.findMethodsByName(refName, false);
|
||||
final PsiMethod[] methods = clazz.findMethodsByName(refName, true);
|
||||
for (PsiMethod method : methods) {
|
||||
result.add(new GroovyResolveResultImpl(method, helper.isAccessible(method, ref, null)));
|
||||
}
|
||||
|
||||
final PsiClass innerClass = clazz.findInnerClassByName(refName, false);
|
||||
final PsiClass innerClass = clazz.findInnerClassByName(refName, true);
|
||||
if (innerClass != null && innerClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
result.add(new GroovyResolveResultImpl(innerClass, helper.isAccessible(innerClass, ref, null)));
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.groovy.mvc.projectView;
|
||||
@@ -226,7 +226,7 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
|
||||
}
|
||||
|
||||
protected ProjectViewTree createTree(final DefaultTreeModel treeModel) {
|
||||
return new ProjectViewTree(treeModel) {
|
||||
return new ProjectViewTree(myProject, treeModel) {
|
||||
public String toString() {
|
||||
return myDescriptor.getFramework().getDisplayName() + " " + super.toString();
|
||||
}
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ public class GroovyOverrideImplementUtil {
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (i > 0) buffer.append(", ");
|
||||
PsiParameter parameter = parameters[i];
|
||||
if (!(parameter instanceof GrParameter && parameter.getTypeElement() == null)) {
|
||||
if (!(parameter instanceof GrParameter && ((GrParameter)parameter).getTypeElementGroovy() == null)) {
|
||||
final PsiType parameterType = substitutor.substitute(parameter.getType());
|
||||
buffer.append(parameterType.getCanonicalText());
|
||||
buffer.append(" ");
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class ClosureGenerator {
|
||||
LOG.assertTrue(allParameters.length == 1);
|
||||
final GrParameter itParameter = allParameters[0];
|
||||
final GrParameter parameter = factory.createParameter("it", itParameter.getType().getCanonicalText(), "null", block);
|
||||
method.getParameterList().addParameterToEnd(parameter);
|
||||
method.getParameterList().add(parameter);
|
||||
}
|
||||
((GroovyFileImpl)method.getContainingFile()).setContextNullable(null);
|
||||
return method;
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.groovy.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class AddConstructorMatchingSuperTest extends GrIntentionTestCase {
|
||||
private static final String HINT = "Create constructor matching super"
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "${TestUtils.testDataPath}intentions/constructorMatchingSuper/"
|
||||
}
|
||||
|
||||
void testGroovyToGroovy() {
|
||||
doTextTest('''\
|
||||
class Base {
|
||||
Base(int p, @Anno int x) throws Exception {}
|
||||
}
|
||||
|
||||
class Derived exten<caret>ds Base {
|
||||
}
|
||||
''', HINT, '''\
|
||||
class Base {
|
||||
Base(int p, @Anno int x) throws Exception {}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
<caret>Derived(int p, @Anno int x) throws Exception {
|
||||
super(p, x)
|
||||
}
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testJavaToGroovy() {
|
||||
myFixture.addClass('''\
|
||||
class Base {
|
||||
Base(int p, @Anno int x) throws Exception {}
|
||||
}
|
||||
''')
|
||||
doTextTest('''\
|
||||
class Derived exten<caret>ds Base {
|
||||
}
|
||||
''', HINT, '''\
|
||||
class Derived extends Base {
|
||||
<caret>def Derived(int p, @Anno int x) throws Exception {
|
||||
super(p, x)
|
||||
}
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testGroovyToJava() {
|
||||
myFixture.addClass('''\
|
||||
class Base {
|
||||
Base(int p, @Override int x) throws Exception {}
|
||||
}
|
||||
''')
|
||||
myFixture.configureByText("a.java", '''\
|
||||
class Derived exten<caret>ds Base {
|
||||
}
|
||||
''')
|
||||
final List<IntentionAction> list = myFixture.filterAvailableIntentions(HINT)
|
||||
myFixture.launchAction(assertOneElement(list))
|
||||
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting()
|
||||
myFixture.checkResult('''\
|
||||
class Derived extends Base {
|
||||
<caret>Derived(int p, @Override int x) throws Exception {
|
||||
super(p, x);
|
||||
}
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
}
|
||||
+6
-7
@@ -16,11 +16,10 @@
|
||||
|
||||
package org.jetbrains.plugins.groovy.intentions;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
import java.util.List;
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
@@ -31,14 +30,14 @@ public abstract class GrIntentionTestCase extends LightCodeInsightFixtureTestCas
|
||||
final List<IntentionAction> list = myFixture.filterAvailableIntentions(hint);
|
||||
if (intentionExists) {
|
||||
myFixture.launchAction(assertOneElement(list));
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
|
||||
}
|
||||
else {
|
||||
if (list.size() > 0) {
|
||||
StringBuilder text = new StringBuilder("available intentions:");
|
||||
for (IntentionAction intentionAction : list) {
|
||||
text.append(intentionAction.getFamilyName()).append(", ");
|
||||
text.append(intentionAction.familyName).append(", ");
|
||||
}
|
||||
fail(text.toString());
|
||||
}
|
||||
@@ -49,7 +48,7 @@ public abstract class GrIntentionTestCase extends LightCodeInsightFixtureTestCas
|
||||
myFixture.configureByText("a.groovy", before);
|
||||
final List<IntentionAction> list = myFixture.filterAvailableIntentions(hint);
|
||||
myFixture.launchAction(assertOneElement(list));
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
|
||||
myFixture.checkResult(after);
|
||||
}
|
||||
|
||||
+34
@@ -992,4 +992,38 @@ def foo(Integer a) {
|
||||
''')
|
||||
assertNotNull(ref.resolve())
|
||||
}
|
||||
|
||||
public void testStaticImportFromSuperClass() {
|
||||
def ref = configureByText('''\
|
||||
import static Derived.fo<caret>o
|
||||
|
||||
class Base {
|
||||
static foo(){print 'foo'}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
}
|
||||
|
||||
foo()
|
||||
''')
|
||||
|
||||
assertNotNull(ref.resolve())
|
||||
}
|
||||
|
||||
public void testUsageOfStaticImportFromSuperClass() {
|
||||
def ref = configureByText('''\
|
||||
import static Derived.foo
|
||||
|
||||
class Base {
|
||||
static foo(){print 'foo'}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
}
|
||||
|
||||
fo<caret>o()
|
||||
''')
|
||||
|
||||
assertNotNull(ref.resolve())
|
||||
}
|
||||
}
|
||||
|
||||
+11
-10
@@ -17,13 +17,13 @@ package org.jetbrains.idea.maven.dom.converters;
|
||||
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.paths.PathReferenceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.xml.*;
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.dom.MavenDomBundle;
|
||||
import org.jetbrains.idea.maven.dom.MavenDomUtil;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
|
||||
import org.jetbrains.idea.maven.dom.references.MavenPathReferenceConverter;
|
||||
import org.jetbrains.idea.maven.model.MavenConstants;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
@@ -53,7 +54,7 @@ public class MavenParentRelativePathConverter extends ResolvingConverter<PsiFile
|
||||
VirtualFile f = contextFile.getParent().findFileByRelativePath(s);
|
||||
if (f == null) return null;
|
||||
|
||||
if (f.isDirectory()) f = f.findFileByRelativePath(MavenConstants.POM_XML);
|
||||
if (f.isDirectory()) f = f.findChild(MavenConstants.POM_XML);
|
||||
if (f == null) return null;
|
||||
|
||||
return context.getPsiManager().findFile(f);
|
||||
@@ -86,7 +87,7 @@ public class MavenParentRelativePathConverter extends ResolvingConverter<PsiFile
|
||||
return ArrayUtil.append(super.getQuickFixes(context), new RelativePathFix(context));
|
||||
}
|
||||
|
||||
private class RelativePathFix implements LocalQuickFix {
|
||||
private static class RelativePathFix implements LocalQuickFix {
|
||||
private final ConvertContext myContext;
|
||||
|
||||
public RelativePathFix(ConvertContext context) {
|
||||
@@ -118,11 +119,11 @@ public class MavenParentRelativePathConverter extends ResolvingConverter<PsiFile
|
||||
|
||||
@NotNull
|
||||
public PsiReference[] createReferences(final GenericDomValue genericDomValue, final PsiElement element, final ConvertContext context) {
|
||||
return createReferences(element, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiReference[] createReferences(@NotNull final PsiElement psiElement, final boolean soft) {
|
||||
return PathReferenceManager.getInstance().createReferences(psiElement, soft);
|
||||
return new MavenPathReferenceConverter(new Condition<PsiFileSystemItem>() {
|
||||
@Override
|
||||
public boolean value(PsiFileSystemItem item) {
|
||||
return item.isDirectory() || item.getName().equals("pom.xml");
|
||||
}
|
||||
}).createReferences(genericDomValue, element, context);
|
||||
}
|
||||
}
|
||||
+1
@@ -130,6 +130,7 @@ public class MavenModulePsiReference extends MavenPsiReference implements LocalQ
|
||||
modulePom,
|
||||
new MavenId(groupId, artifactId, version),
|
||||
myWithParent ? id : null,
|
||||
myPsiFile.getVirtualFile(),
|
||||
true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class MavenPathReferenceConverter extends PathReferenceConverter {
|
||||
TextRange range = manipulator.getRangeInElement(element);
|
||||
String text = range.substring(element.getText());
|
||||
|
||||
FileReferenceSet set = new FileReferenceSet(text, element, range.getStartOffset(), null, SystemInfo.isFileSystemCaseSensitive, true) {
|
||||
FileReferenceSet set = new FileReferenceSet(text, element, range.getStartOffset(), null, SystemInfo.isFileSystemCaseSensitive, false) {
|
||||
|
||||
private MavenDomProjectModel model;
|
||||
|
||||
|
||||
@@ -285,10 +285,18 @@ public class MavenUtil {
|
||||
return "<img src=\"" + url + "\"> ";
|
||||
}
|
||||
|
||||
public static void runOrApplyMavenProjectFileTemplate(Project project,
|
||||
VirtualFile file,
|
||||
MavenId projectId,
|
||||
boolean interactive) throws IOException {
|
||||
runOrApplyMavenProjectFileTemplate(project, file, projectId, null, null, interactive);
|
||||
}
|
||||
|
||||
public static void runOrApplyMavenProjectFileTemplate(Project project,
|
||||
VirtualFile file,
|
||||
MavenId projectId,
|
||||
MavenId parentId,
|
||||
VirtualFile parentFile,
|
||||
boolean interactive) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
Properties conditions = new Properties();
|
||||
@@ -300,6 +308,21 @@ public class MavenUtil {
|
||||
properties.setProperty("PARENT_GROUP_ID", parentId.getGroupId());
|
||||
properties.setProperty("PARENT_ARTIFACT_ID", parentId.getArtifactId());
|
||||
properties.setProperty("PARENT_VERSION", parentId.getVersion());
|
||||
|
||||
if (parentFile != null) {
|
||||
VirtualFile modulePath = file.getParent();
|
||||
VirtualFile parentModulePath = parentFile.getParent();
|
||||
|
||||
if (modulePath.getParent() != parentModulePath) {
|
||||
String relativePath = VfsUtil.getPath(file, parentModulePath, '/');
|
||||
if (relativePath != null) {
|
||||
if (relativePath.endsWith("/")) relativePath = relativePath.substring(0, relativePath.length() - 1);
|
||||
|
||||
conditions.setProperty("HAS_RELATIVE_PATH", "true");
|
||||
properties.setProperty("PARENT_RELATIVE_PATH", relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
runOrApplyFileTemplate(project, file, MavenFileTemplateGroupFactory.MAVEN_PROJECT_XML_TEMPLATE, properties, conditions, interactive);
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class MavenModuleBuilderHelper {
|
||||
VirtualFile file;
|
||||
try {
|
||||
file = root.createChildData(this, MavenConstants.POM_XML);
|
||||
MavenUtil.runOrApplyMavenProjectFileTemplate(project, file, myProjectId, null, isInteractive);
|
||||
MavenUtil.runOrApplyMavenProjectFileTemplate(project, file, myProjectId, isInteractive);
|
||||
result.setResult(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<groupId>${PARENT_GROUP_ID}</groupId>
|
||||
<artifactId>${PARENT_ARTIFACT_ID}</artifactId>
|
||||
<version>${PARENT_VERSION}</version>
|
||||
#if (${HAS_RELATIVE_PATH})
|
||||
<relativePath>${PARENT_RELATIVE_PATH}</relativePath>
|
||||
#end
|
||||
</parent>
|
||||
|
||||
#end
|
||||
|
||||
@@ -303,7 +303,11 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase {
|
||||
}
|
||||
|
||||
protected IntentionAction getIntentionAtCaret(String intentionName) throws IOException {
|
||||
configTest(myProjectPom);
|
||||
return getIntentionAtCaret(myProjectPom, intentionName);
|
||||
}
|
||||
|
||||
protected IntentionAction getIntentionAtCaret(VirtualFile pomFile, String intentionName) throws IOException {
|
||||
configTest(pomFile);
|
||||
try {
|
||||
List<IntentionAction> intentions = myFixture.getAvailableIntentions();
|
||||
|
||||
|
||||
+17
@@ -18,6 +18,8 @@ package org.jetbrains.idea.maven.dom;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MavenModelValidationTest extends MavenDomWithIndicesTestCase {
|
||||
@Override
|
||||
protected void setUpInWriteAction() throws Exception {
|
||||
@@ -27,6 +29,21 @@ public class MavenModelValidationTest extends MavenDomWithIndicesTestCase {
|
||||
"<version>1</version>");
|
||||
}
|
||||
|
||||
public void testCompletionRelativePath() throws Exception {
|
||||
createProjectSubDir("src");
|
||||
createProjectSubFile("a.txt", "");
|
||||
|
||||
VirtualFile modulePom = createModulePom("module1",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>module1</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<parent>" +
|
||||
"<relativePath>../<caret></relativePath>" +
|
||||
"</parent>");
|
||||
|
||||
assertCompletionVariants(modulePom, "src", "module1", "pom.xml");
|
||||
}
|
||||
|
||||
public void testUnderstandingProjectSchemaWithoutNamespace() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
|
||||
+90
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public class MavenModuleCompletionAndResolutionTest extends MavenDomWithIndicesTestCase {
|
||||
@@ -467,6 +468,95 @@ public class MavenModuleCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
"</project>");
|
||||
}
|
||||
|
||||
public void testCreateModuleWithParentQuickFix2() throws Throwable {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>");
|
||||
importProject();
|
||||
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
|
||||
"<modules>" +
|
||||
" <module>ppp/new<caret>Module</module>" +
|
||||
"</modules>");
|
||||
|
||||
IntentionAction i = getIntentionAtCaret(CREATE_MODULE_WITH_PARENT_INTENTION);
|
||||
assertNotNull(i);
|
||||
myFixture.launchAction(i);
|
||||
|
||||
assertCreateModuleFixResult(
|
||||
"ppp/newModule/pom.xml",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
|
||||
" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" +
|
||||
" <modelVersion>4.0.0</modelVersion>\n" +
|
||||
"\n" +
|
||||
" <parent>\n" +
|
||||
" <groupId>test</groupId>\n" +
|
||||
" <artifactId>project</artifactId>\n" +
|
||||
" <version>1</version>\n" +
|
||||
" <relativePath>../..</relativePath>\n" +
|
||||
" </parent>\n" +
|
||||
"\n" +
|
||||
" <groupId>test</groupId>\n" +
|
||||
" <artifactId>newModule</artifactId>\n" +
|
||||
" <version>1</version>\n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"</project>");
|
||||
}
|
||||
|
||||
public void testCreateModuleWithParentQuickFix3() throws Throwable {
|
||||
VirtualFile parentPom = createModulePom("parent",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>");
|
||||
|
||||
importProject(parentPom);
|
||||
|
||||
VfsUtil.saveText(parentPom, createPomXml(
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<packaging>pom</packaging>" +
|
||||
|
||||
"<modules>" +
|
||||
" <module>../ppp/new<caret>Module</module>" +
|
||||
"</modules>"));
|
||||
|
||||
IntentionAction i = getIntentionAtCaret(parentPom, CREATE_MODULE_WITH_PARENT_INTENTION);
|
||||
assertNotNull(i);
|
||||
myFixture.launchAction(i);
|
||||
|
||||
assertCreateModuleFixResult(
|
||||
"ppp/newModule/pom.xml",
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
|
||||
" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" +
|
||||
" <modelVersion>4.0.0</modelVersion>\n" +
|
||||
"\n" +
|
||||
" <parent>\n" +
|
||||
" <groupId>test</groupId>\n" +
|
||||
" <artifactId>project</artifactId>\n" +
|
||||
" <version>1</version>\n" +
|
||||
" <relativePath>../../parent</relativePath>\n" +
|
||||
" </parent>\n" +
|
||||
"\n" +
|
||||
" <groupId>test</groupId>\n" +
|
||||
" <artifactId>newModule</artifactId>\n" +
|
||||
" <version>1</version>\n" +
|
||||
"\n" +
|
||||
" \n" +
|
||||
"</project>");
|
||||
}
|
||||
|
||||
public void testDoesNotShowCreatePomQuickFixForEmptyModuleTag() throws Throwable {
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.designer.model;
|
||||
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface IComponentDecorator {
|
||||
void decorateTree(ColoredTreeCellRenderer renderer);
|
||||
}
|
||||
@@ -820,6 +820,8 @@
|
||||
|
||||
<debuggerEditorTextProvider language="JAVA" implementationClass="com.intellij.debugger.impl.JavaEditorTextProviderImpl"/>
|
||||
|
||||
<constructorBodyGenerator language="JAVA" implementationClass="com.intellij.codeInsight.generation.JavaConstructorBodyWithSuperCallGenerator"/>
|
||||
|
||||
<quoteHandler fileType="JAVA" className="com.intellij.codeInsight.editorActions.JavaQuoteHandler"/>
|
||||
<typedHandler implementation="com.intellij.codeInsight.editorActions.JavaTypedHandler" id="java"/>
|
||||
<typedHandler implementation="com.intellij.codeInsight.editorActions.JavadocTypedHandler" id="javadoc"/>
|
||||
|
||||
Reference in New Issue
Block a user