Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vladimir Orlov
2014-02-03 19:08:42 +04:00
121 changed files with 1290 additions and 736 deletions
+1 -1
View File
@@ -268,7 +268,7 @@ public def layoutCommunityPlugins(String home) {
}
}
dir("properties") {
pluginDir("properties") {
dir("lib") {
jar("properties.jar") {
module("properties-psi-api")
@@ -112,7 +112,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
private final MultiMap<TemplatesGroup,ProjectTemplate> myTemplatesMap;
private boolean myRemoteTemplatesLoaded;
private Cards myCurrentCard;
private boolean myNeedDownload;
public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) {
myContext = context;
@@ -163,7 +162,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myConfigurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
if (myCurrentCard == Cards.FRAMEWORKS) {
if (isFrameworksMode()) {
myFrameworksPanel.addSupport(module, rootModel);
}
}
@@ -210,6 +209,10 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myTemplatesList.restoreSelection();
}
private boolean isFrameworksMode() {
return myCurrentCard == Cards.FRAMEWORKS && getSelectedBuilder().equals(myContext.getProjectBuilder());
}
private List<TemplatesGroup> fillTemplatesMap(WizardContext context) {
List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
@@ -306,7 +309,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
// new TemplatesGroup selected
public void projectTypeChanged() {
myNeedDownload = false;
TemplatesGroup group = getSelectedGroup();
if (group == null) return;
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
@@ -332,7 +334,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myFrameworksPanel.setProviders(providers);
}
getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);
myNeedDownload = true;
showCard(FRAMEWORKS_CARD);
}
@@ -412,7 +413,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
}
public void onWizardFinished() throws CommitStepException {
if (myNeedDownload) {
if (isFrameworksMode()) {
boolean ok = myFrameworksPanel.downloadLibraries();
if (!ok) {
int answer = Messages.showYesNoDialog(getComponent(),
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class ImplementMethodsFix extends LocalQuickFixAndIntentionActionOnPsiEle
@Override
@NotNull
public String getFamilyName() {
return QuickFixBundle.message("implement.methods.fix");
return getText();
}
@Override
@@ -113,6 +113,7 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
if (classes.length == 0) return Collections.emptyList();
List<PsiClass> classList = new ArrayList<PsiClass>(classes.length);
boolean isAnnotationReference = myElement.getParent() instanceof PsiAnnotation;
final PsiFile file = myElement.getContainingFile();
for (PsiClass aClass : classes) {
if (isAnnotationReference && !aClass.isAnnotationType()) continue;
if (JavaCompletionUtil.isInExcludedPackage(aClass, false)) continue;
@@ -120,7 +121,7 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
String qName = aClass.getQualifiedName();
if (qName != null) { //filter local classes
if (qName.indexOf('.') == -1) continue; //do not show classes from default package)
if (qName.endsWith(name) && ImportFilter.shouldImport(qName)) {
if (qName.endsWith(name) && ImportFilter.shouldImport(file, qName)) {
if (isAccessible(aClass, myElement)) {
classList.add(aClass);
}
@@ -370,7 +370,7 @@ public class ImportHelper{
String className = refClass.getQualifiedName();
if (className == null) return true;
if (!ImportFilter.shouldImport(className)) {
if (!ImportFilter.shouldImport(file, className)) {
return false;
}
String packageName = getPackageOrClassName(className);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,6 @@ package com.intellij.refactoring.makeStatic;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -50,6 +48,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
public static final String REFACTORING_NAME = RefactoringBundle.message("make.method.static.title");
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.makeMethodStatic.MakeMethodStaticHandler");
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
@@ -71,6 +70,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
invoke(project, new PsiElement[]{element}, dataContext);
}
@Override
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
if(elements.length != 1 || !(elements[0] instanceof PsiTypeParameterListOwner)) return;
@@ -108,10 +108,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
@Override
public boolean process(PsiReference reference) {
final PsiElement element = reference.getElement();
if (element instanceof PsiMethodReferenceExpression) {
return false;
}
return true;
return !(element instanceof PsiMethodReferenceExpression);
}
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,6 +107,7 @@ public class InlineUtil {
builder.append(exprType.getCanonicalText());
builder.append("[]{");
builder.append(StringUtil.join(Arrays.asList(arguments), new Function<PsiExpression, String>() {
@Override
public String fun(final PsiExpression expr) {
return expr.getText();
}
@@ -294,8 +295,10 @@ public class InlineUtil {
public static boolean allUsagesAreTailCalls(final PsiMethod method) {
final List<PsiReference> nonTailCallUsages = Collections.synchronizedList(new ArrayList<PsiReference>());
boolean result = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ReferencesSearch.search(method).forEach(new Processor<PsiReference>() {
@Override
public boolean process(final PsiReference psiReference) {
ProgressManager.checkCanceled();
if (getTailCallType(psiReference) == TailCallType.None) {
@@ -1,7 +1,9 @@
package com.intellij.codeInsight;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Eugene.Kudelevsky
@@ -9,11 +11,11 @@ import org.jetbrains.annotations.NotNull;
public abstract class ImportFilter {
public static final ExtensionPointName<ImportFilter> EP_NAME = new ExtensionPointName<ImportFilter>("com.intellij.importFilter");
public abstract boolean shouldUseFullyQualifiedName(@NotNull String classQualifiedName);
public abstract boolean shouldUseFullyQualifiedName(@Nullable PsiFile targetFile, @NotNull String classQualifiedName);
public static boolean shouldImport(@NotNull String classQualifiedName) {
public static boolean shouldImport(@Nullable PsiFile targetFile, @NotNull String classQualifiedName) {
for (ImportFilter filter : EP_NAME.getExtensions()) {
if (filter.shouldUseFullyQualifiedName(classQualifiedName)) {
if (filter.shouldUseFullyQualifiedName(targetFile, classQualifiedName)) {
return false;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -370,7 +370,7 @@ public class PsiImplUtil {
// todo[r.sh] cache?
@Nullable
public static Set<TargetType> getAnnotationTargets(PsiClass annotationType) {
public static Set<TargetType> getAnnotationTargets(@NotNull PsiClass annotationType) {
if (!annotationType.isAnnotationType()) return null;
PsiModifierList modifierList = annotationType.getModifierList();
if (modifierList == null) return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ import java.io.File;
import java.util.Collection;
/**
* This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run.
* This class intended for "heavy-loaded" tests only, e.g. those need to setup separate project directory structure to run.
* For "lightweight" tests use LightAdvHighlightingTest.
*/
public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -189,7 +189,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
return findActionWithText(getAvailableActions(), text);
}
public static IntentionAction findActionWithText(final List<IntentionAction> actions, final String text) {
public static IntentionAction findActionWithText(@NotNull List<IntentionAction> actions, final String text) {
for (IntentionAction action : actions) {
if (text.equals(action.getText())) {
return action;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl;
@@ -19,7 +34,7 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
private final ProblemsHolder myHolder;
private final ExternalAnnotator myAnnotator;
private boolean myOnTheFly;
private final boolean myOnTheFly;
public ExternalAnnotatorInspectionVisitor(ProblemsHolder holder, ExternalAnnotator annotator, boolean onTheFly) {
myHolder = holder;
@@ -27,17 +42,19 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
myOnTheFly = onTheFly;
}
public static ProblemDescriptor[] checkFileWithExternalAnnotator(PsiFile file,
InspectionManager manager,
boolean isOnTheFly, ExternalAnnotator annotator) {
@NotNull
public static <Init,Result> ProblemDescriptor[] checkFileWithExternalAnnotator(@NotNull PsiFile file,
@NotNull InspectionManager manager,
boolean isOnTheFly,
@NotNull ExternalAnnotator<Init,Result> annotator) {
if (isOnTheFly) {
// concrete JSLinterExternalAnnotator implementation does this work
return ProblemDescriptor.EMPTY_ARRAY;
}
Object info = annotator.collectInformation(file);
Init info = annotator.collectInformation(file);
if (info != null) {
Object annotationResult = annotator.doAnnotate(info);
Result annotationResult = annotator.doAnnotate(info);
if (annotationResult == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
@@ -48,10 +65,11 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
return ProblemDescriptor.EMPTY_ARRAY;
}
@NotNull
private static ProblemDescriptor[] convertToProblemDescriptors(@NotNull final List<Annotation> annotations,
@NotNull final InspectionManager manager,
@NotNull final PsiFile file) {
if (annotations.size() == 0) {
if (annotations.isEmpty()) {
return ProblemDescriptor.EMPTY_ARRAY;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -102,6 +102,7 @@ public class ProblemDescriptorBase extends CommonProblemDescriptorImpl implement
return PsiTreeUtil.findCommonParent(startElement, endElement);
}
@Override
@Nullable
public TextRange getTextRangeInElement() {
return myTextRangeInElement;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,4 +63,7 @@ public abstract class ModalityState {
}
public abstract boolean dominates(@NotNull ModalityState anotherState);
@Override
public abstract String toString();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,11 +58,13 @@ public abstract class ObjectPattern<T, Self extends ObjectPattern<T, Self>> impl
}
public Self andNot(final ElementPattern pattern) {
return and(StandardPatterns.not(pattern));
ElementPattern<T> not = StandardPatterns.not(pattern);
return and(not);
}
public Self andOr(final ElementPattern... patterns) {
return and(StandardPatterns.or(patterns));
public Self andOr(@NotNull ElementPattern... patterns) {
ElementPattern or = StandardPatterns.or(patterns);
return and(or);
}
public Self and(final ElementPattern pattern) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -195,6 +195,11 @@ public class MockApplication extends MockComponentManager implements Application
public boolean dominates(@NotNull ModalityState anotherState) {
return false;
}
@Override
public String toString() {
return "NONE";
}
};
}
return MODALITY_STATE_NONE;
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.event.EditorMouseMotionListener;
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.UserDataHolder;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,9 +26,9 @@ import org.jetbrains.annotations.NotNull;
* @author Denis Zhdanov
* @since 4/25/11 1:16 PM
*/
public interface ConsoleActionsPostProcessor {
public abstract class ConsoleActionsPostProcessor {
ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
public static final ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
/**
* Allows to adjust actions to use within the given console instance.
@@ -40,5 +40,12 @@ public interface ConsoleActionsPostProcessor {
* @return actions to use within the given console instance (given actions may be returned by default)
*/
@NotNull
AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions);
public AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
@NotNull
public AnAction[] postProcessPopupActions(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
}
@@ -53,4 +53,9 @@ public abstract class AbstractModuleBuilder extends ProjectBuilder {
public abstract void setModuleFilePath(@NonNls String path);
public abstract void setContentEntryPath(String moduleRootPath);
@Override
public boolean equals(Object obj) {
return obj instanceof AbstractModuleBuilder && getBuilderId() != null && getBuilderId().equals(((AbstractModuleBuilder)obj).getBuilderId());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,9 +107,11 @@ public class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable
application.invokeLater(new Runnable() {
@Override
public void run() {
EditorMarkupModel markupModel = (EditorMarkupModel)editor.getMarkupModel();
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
if (!editor.isDisposed()) {
EditorMarkupModel markupModel = (EditorMarkupModel)editor.getMarkupModel();
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
}
}
}, ModalityState.stateForComponent(editor.getComponent()), myProject.getDisposed());
}
@@ -922,7 +922,21 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
if (group == null) {
group = (ActionGroup)actionManager.getAction(CONSOLE_VIEW_POPUP_MENU);
}
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
final ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
AnAction[] result = group.getChildren(null);
for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
result = postProcessor.postProcessPopupActions(this, result);
}
final AnAction[] processedActions = result;
final ActionGroup processedGroup = new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return processedActions;
}
};
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, processedGroup);
menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl;
import com.intellij.util.FileContentUtil;
import com.intellij.util.FileContentUtilCore;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -0,0 +1,104 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.ui.dialogs;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.ScrollPaneFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.ResourceBundle;
public class AgreementDialog extends DialogWrapper {
private final Font myFont = new Font("SansSerif", Font.PLAIN, 12);
private final ResourceBundle myBundle = ResourceBundle.getBundle("messages.LicenseCommonBundle");
private final String myText;
private JCheckBox myAcceptCheckBox;
private boolean myOK = false;
public AgreementDialog(String text, String programName) {
super(null, false, true);
getPeer().setAppIcons();
myText = text;
String title;
if (programName != null) {
title = MessageFormat.format(myBundle.getString("license.agreement.title.for"), programName);
}
else {
title = myBundle.getString("license.agreement.title");
}
setTitle(title);
init();
getOKAction().setEnabled(false);
}
protected void doOKAction() {
myOK = true;
super.doOKAction();
}
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new BorderLayout());
String text = myBundle.getString("license.agreement.prompt");
JLabel licensePrompt = new JLabel(text);
licensePrompt.setFocusable(false);
licensePrompt.setFont(myFont);
licensePrompt.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 5));
panel.add(licensePrompt, BorderLayout.WEST);
panel.add(new JPanel(), BorderLayout.CENTER);
return panel;
}
public boolean isAgreed() {
return myOK && myAcceptCheckBox.isSelected();
}
protected JComponent createCenterPanel() {
JPanel optionsPanel = new JPanel(new BorderLayout());
JTextArea licenseTextArea = new JTextArea(myText, 20, 50);
licenseTextArea.getCaret().setDot(0);
licenseTextArea.setFont(myFont);
licenseTextArea.setLineWrap(true);
licenseTextArea.setWrapStyleWord(true);
licenseTextArea.setEditable(false);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(licenseTextArea);
optionsPanel.add(scrollPane, BorderLayout.CENTER);
JPanel agreePanel = new JPanel(new GridLayout(1, 1));
agreePanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
myAcceptCheckBox = new JCheckBox(myBundle.getString("license.agreement.accept.checkbox"));
myAcceptCheckBox.setMnemonic(myAcceptCheckBox.getText().charAt(0));
myAcceptCheckBox.setFont(myFont);
agreePanel.add(myAcceptCheckBox);
optionsPanel.add(agreePanel, BorderLayout.SOUTH);
myAcceptCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
getOKAction().setEnabled(myAcceptCheckBox.isSelected());
}
});
return optionsPanel;
}
}
@@ -357,7 +357,7 @@ public class Alarm implements Disposable {
@Override
public String toString() {
Runnable task = getTask();
return super.toString() + (task != null ? " "+task:null);
return super.toString() + (task != null ? ": "+task : "");
}
}
@@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.intellij.util.net.ssl.CertificateWrapper.CommonField.COMMON_NAME;
import static com.intellij.util.net.ssl.CertificateUtil.getCommonName;
import static com.intellij.util.net.ssl.ConfirmingTrustManager.MutableTrustManager;
/**
@@ -63,7 +63,7 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
if (!new CertificateWrapper(certificate).isValid()) {
setForeground(UIUtil.getLabelDisabledForeground());
}
setText(new CertificateWrapper(certificate).getSubjectField(COMMON_NAME));
setText(getCommonName(certificate));
}
});
@@ -136,7 +136,7 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
myDetailsPanel.add(scrollPane, uniqueName);
}
private String getCardName(X509Certificate certificate) {
private static String getCardName(X509Certificate certificate) {
return certificate.getSubjectX500Principal().getName();
}
@@ -203,13 +203,13 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
for (X509Certificate certificate : added) {
if (!myTrustManager.addCertificate(certificate)) {
throw new ConfigurationException("Cannot add certificate", "Cannot Add Certificate");
throw new ConfigurationException("Cannot add certificate for " + getCommonName(certificate), "Cannot Add Certificate");
}
}
for (X509Certificate certificate : removed) {
if (!myTrustManager.removeCertificate(certificate)) {
throw new ConfigurationException("Cannot remove certificate", "Cannot Remove Certificate");
throw new ConfigurationException("Cannot remove certificate for " + getCommonName(certificate), "Cannot Remove Certificate");
}
}
@@ -256,12 +256,18 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
@Override
public void certificateAdded(X509Certificate certificate) {
getListModel().add(certificate);
CollectionListModel<X509Certificate> model = getListModel();
if (model.getElementIndex(certificate) < 0) {
model.add(certificate);
}
addCertificatePanel(certificate);
}
@Override
public void certificateRemoved(X509Certificate certificate) {
getListModel().remove(certificate);
CollectionListModel<X509Certificate> model = getListModel();
if (model.getElementIndex(certificate) >= 0) {
model.remove(certificate);
}
}
}
@@ -63,4 +63,11 @@ public class CertificateUtil {
StreamUtil.closeStream(stream);
}
}
/**
* @return subjects common name, usually it's domain name pattern, e.g. *.github.com
*/
public static String getCommonName(@NotNull X509Certificate certificate) {
return new CertificateWrapper(certificate).getSubjectField(CertificateWrapper.CommonField.COMMON_NAME);
}
}
@@ -260,7 +260,7 @@ public class ConfirmingTrustManager extends ClientOnlyTrustManager {
}
private static String createAlias(@NotNull X509Certificate certificate) {
return new CertificateWrapper(certificate).getSubjectField(CertificateWrapper.CommonField.COMMON_NAME);
return CertificateUtil.getCommonName(certificate);
}
/**
@@ -287,6 +287,10 @@ public class ConfirmingTrustManager extends ClientOnlyTrustManager {
}
// for listeners
X509Certificate certificate = getCertificate(alias);
if (certificate == null) {
LOG.error("No certificate found for alias: " + alias);
return false;
}
myKeyStore.deleteEntry(alias);
flushKeyStore();
// trust manager should be updated each time its key store was modified
@@ -151,6 +151,8 @@ Tree.paintLines=false
Tree.textBackground=ffffff
Tree.selectionBorderColor=3875d6
EditorPane.background=ffffff
List.background=ffffff
Hyperlink.linkColor=589df6
@@ -57,10 +57,10 @@ public class LaterInvocator {
}
private static class RunnableInfo {
final Runnable runnable;
final ModalityState modalityState;
final Condition<Object> expired;
final ActionCallback callback;
@NotNull private final Runnable runnable;
@NotNull private final ModalityState modalityState;
@NotNull private final Condition<Object> expired;
@NotNull private final ActionCallback callback;
public RunnableInfo(@NotNull Runnable runnable,
@NotNull ModalityState modalityState,
@@ -74,7 +74,7 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "[runnable: " + runnable + "; state=" + modalityState + "] ";
return "[runnable: " + runnable + "; state=" + modalityState + (expired.value(null) ? "; expired" : "")+"] ";
}
}
@@ -88,21 +88,12 @@ public class LaterInvocator {
private static final EventDispatcher<ModalityStateListener> ourModalityStateMulticaster =
EventDispatcher.create(ModalityStateListener.class);
private static final ArrayList<RunnableInfo> ourForcedFlushQueue = new ArrayList<RunnableInfo>();
public static void addModalityStateListener(@NotNull ModalityStateListener listener) {
ourModalityStateMulticaster.addListener(listener);
}
private static final List<RunnableInfo> ourForcedFlushQueue = new ArrayList<RunnableInfo>();
public static void addModalityStateListener(@NotNull ModalityStateListener listener, @NotNull Disposable parentDisposable) {
ourModalityStateMulticaster.addListener(listener, parentDisposable);
}
public static void removeModalityStateListener(@NotNull ModalityStateListener listener) {
ourModalityStateMulticaster.removeListener(listener);
}
@NotNull
static ModalityStateEx modalityStateForWindow(@NotNull Window window) {
int index = ourModalEntities.indexOf(window);
@@ -113,9 +104,7 @@ public class LaterInvocator {
if (window instanceof Dialog && ((Dialog)window).isModal()) {
return ownerState.appendEntity(window);
}
else {
return ownerState;
}
return ownerState;
}
ArrayList<Object> result = new ArrayList<Object>();
@@ -132,27 +121,32 @@ public class LaterInvocator {
return new ModalityStateEx(result.toArray());
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable) {
return invokeLater(runnable, Conditions.FALSE);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) {
ModalityState modalityState = ModalityState.defaultModalityState();
return invokeLater(runnable, modalityState, expired);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
return invokeLater(runnable, modalityState, Conditions.FALSE);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable,
@NotNull ModalityState modalityState,
@NotNull Condition<Object> expired) {
ourFrequentEventDetector.eventHappened();
final ActionCallback callback = new ActionCallback();
RunnableInfo runnableInfo = new RunnableInfo(runnable, modalityState, expired, callback);
synchronized (LOCK) {
ourQueue.add(new RunnableInfo(runnable, modalityState, expired, callback));
ourQueue.add(runnableInfo);
}
requestFlush();
return callback;
@@ -177,7 +171,7 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "InvokeAndWait[" + runnable.toString() + "]";
return "InvokeAndWait[" + runnable + "]";
}
};
invokeLater(runnable1, modalityState);
@@ -326,7 +320,7 @@ public class LaterInvocator {
lastInfo.callback.setDone();
}
catch (ProcessCanceledException ex) {
// ignore
// ignore
}
catch (Throwable t) {
if (t instanceof StackOverflowError) {
@@ -348,20 +342,23 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "LaterInvocator[lastRunnable=" + myLastInfo + "]";
return "LaterInvocator.FlushQueue" + (myLastInfo == null ? "" : " lastInfo="+myLastInfo);
}
}
@TestOnly
public static List<Object> dumpQueue() {
static String dumpQueue() {
synchronized (LOCK) {
if (!ourQueue.isEmpty()) {
ArrayList<Object> r = new ArrayList<Object>();
r.addAll(ourQueue);
Collections.reverse(r);
return r;
@NonNls String result = "";
if (!ourForcedFlushQueue.isEmpty()) {
result = "(Forced queue: " + ourForcedFlushQueue + ") ";
}
List<RunnableInfo> r = new ArrayList<RunnableInfo>(ourQueue);
result += r + (ourQueueSkipCount == 0 ? "" : " (ourQueueSkipCount="+ourQueueSkipCount+")")
+ (ourModalEntities.isEmpty() ? " (non-modal)" : " (modal entities: "+ourModalEntities+")"
+ (FLUSHER_SCHEDULED.get() ? " (Flusher scheduled)" : "")
);
return result;
}
return null;
}
}
@@ -0,0 +1,103 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.actions;
import com.intellij.CommonBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.Map;
public class HighlightModeAction extends ComboBoxAction implements DumbAware {
private final Map<HighlightMode, AnAction> myActions = new HashMap<HighlightMode, AnAction>();
private static final HighlightMode[] ourActionOrder =
new HighlightMode[]{HighlightMode.BY_WORD, HighlightMode.BY_LINE, HighlightMode.NO_HIGHLIGHTING};
public HighlightModeAction() {
myActions.put(HighlightMode.BY_WORD,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.by.word"), HighlightMode.BY_WORD));
myActions.put(HighlightMode.BY_LINE,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.by.line"), HighlightMode.BY_LINE));
myActions.put(HighlightMode.NO_HIGHLIGHTING,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.no.highlighting"),
HighlightMode.NO_HIGHLIGHTING));
}
@Override
public JComponent createCustomComponent(final Presentation presentation) {
JPanel panel = new JPanel(new BorderLayout());
final JLabel label = new JLabel(CommonBundle.message("diff.acton.highlight.mode.action.name"));
label.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
panel.add(label, BorderLayout.WEST);
panel.add(super.createCustomComponent(presentation), BorderLayout.CENTER);
return panel;
}
@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
DefaultActionGroup actionGroup = new DefaultActionGroup();
for (HighlightMode comparisonPolicy : ourActionOrder) {
actionGroup.add(myActions.get(comparisonPolicy));
}
return actionGroup;
}
public void update(AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
DiffPanelEx diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null && diffPanel.getComponent().isDisplayable()) {
AnAction action = myActions.get(diffPanel.getHighlightMode());
Presentation templatePresentation = action.getTemplatePresentation();
presentation.setIcon(templatePresentation.getIcon());
presentation.setText(templatePresentation.getText());
presentation.setEnabled(true);
}
else {
presentation.setIcon(null);
presentation.setText(DiffBundle.message("diff.acton.highlight.mode.not.available.action.name"));
presentation.setEnabled(false);
}
}
private static class SetHighlightModeAction extends AnAction implements DumbAware {
private final HighlightMode myHighlightMode;
public SetHighlightModeAction(String text, HighlightMode mode) {
super(text);
myHighlightMode = mode;
}
public void actionPerformed(AnActionEvent e) {
final DiffPanelImpl diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
diffPanel.setHighlightMode(myHighlightMode);
}
}
}
}
@@ -82,7 +82,7 @@ public class IgnoreWhiteSpacesAction extends ComboBoxAction implements DumbAware
}
}
private static class IgnoringPolicyAction extends AnAction {
private static class IgnoringPolicyAction extends AnAction implements DumbAware {
private final ComparisonPolicy myPolicy;
public IgnoringPolicyAction(String text, ComparisonPolicy policy) {
@@ -0,0 +1,50 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.ToggleActionButton;
import javax.swing.*;
public class ToggleAutoScrollAction extends ToggleActionButton implements DumbAware {
public ToggleAutoScrollAction() {
super("Auto Scroll", AllIcons.General.AutoscrollToSource);
}
@Override
public boolean isSelected(AnActionEvent e) {
DiffPanelEx diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
return diffPanel.isAutoScrollEnabled();
}
else {
return true;
}
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
final DiffPanelImpl diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
diffPanel.setAutoScrollEnabled(state);
}
}
}
@@ -27,6 +27,7 @@ package com.intellij.openapi.diff.ex;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diff.DiffPanel;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.editor.Editor;
import org.jetbrains.annotations.Nullable;
@@ -41,4 +42,12 @@ public interface DiffPanelEx extends DiffPanel, Disposable {
void setComparisonPolicy(ComparisonPolicy comparisonPolicy);
ComparisonPolicy getComparisonPolicy();
void setAutoScrollEnabled(boolean enabled);
boolean isAutoScrollEnabled();
void setHighlightMode(HighlightMode highlightMode);
HighlightMode getHighlightMode();
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.*;
import com.intellij.openapi.diff.actions.MergeActionGroup;
import com.intellij.openapi.diff.actions.ToggleAutoScrollAction;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.ex.DiffPanelOptions;
import com.intellij.openapi.diff.impl.external.DiffManagerImpl;
@@ -33,6 +34,7 @@ import com.intellij.openapi.diff.impl.fragments.Fragment;
import com.intellij.openapi.diff.impl.fragments.FragmentList;
import com.intellij.openapi.diff.impl.highlighting.DiffPanelState;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.diff.impl.processing.HorizontalDiffSplitter;
import com.intellij.openapi.diff.impl.settings.DiffMergeEditorSetting;
import com.intellij.openapi.diff.impl.settings.DiffMergeSettings;
@@ -110,6 +112,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
public void customize(DiffToolbar toolbar) {
ActionManager actionManager = ActionManager.getInstance();
toolbar.addAction(actionManager.getAction("DiffPanel.Toolbar"));
toolbar.addSeparator();
toolbar.addAction(new ToggleAutoScrollAction());
toolbar.addSeparator();
toolbar.addAction(actionManager.getAction("ContextHelp"));
toolbar.addAction(getEditSourceAction());
toolbar.addSeparator();
@@ -467,10 +472,27 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
}
public void setAutoScrollEnabled(boolean enabled) {
myScrollSupport.setEnabled(enabled);
}
public boolean isAutoScrollEnabled() {
return myScrollSupport.isEnabled();
}
public void setComparisonPolicy(ComparisonPolicy comparisonPolicy) {
setComparisonPolicy(comparisonPolicy, true);
}
public void setHighlightMode(HighlightMode highlightMode) {
myData.setHighlightMode(highlightMode);
rediff();
}
public HighlightMode getHighlightMode() {
return myData.getHighlightMode();
}
public Rediffers getDiffUpdater() {
return myDiffUpdater;
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.diff.impl.fragments.FragmentList;
import com.intellij.openapi.diff.impl.fragments.FragmentListImpl;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.processing.DiffPolicy;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.diff.impl.processing.TextCompareProcessor;
import com.intellij.openapi.diff.impl.splitter.LineBlocks;
import com.intellij.openapi.project.Project;
@@ -37,6 +38,7 @@ import java.util.Iterator;
public abstract class SimpleDiffPanelState implements Disposable {
protected ComparisonPolicy myComparisonPolicy = ComparisonPolicy.DEFAULT;
protected DiffPolicy myDiffPolicy;
protected HighlightMode myHighlightMode;
protected final EditorPlaceHolder myAppender1;
protected final EditorPlaceHolder myAppender2;
protected FragmentList myFragmentList = FragmentList.EMPTY;
@@ -47,6 +49,7 @@ public abstract class SimpleDiffPanelState implements Disposable {
myAppender2 = createEditorWrapper(project, changeListener, FragmentSide.SIDE2);
myProject = project;
myDiffPolicy = DiffPolicy.LINES_WO_FORMATTING;
myHighlightMode = HighlightMode.BY_WORD;
Disposer.register(parentDisposable, this);
}
@@ -72,6 +75,14 @@ public abstract class SimpleDiffPanelState implements Disposable {
return myComparisonPolicy;
}
public HighlightMode getHighlightMode() {
return myHighlightMode;
}
public void setHighlightMode(HighlightMode highlightMode) {
myHighlightMode = highlightMode;
}
public void dispose() {
}
@@ -105,7 +116,12 @@ public abstract class SimpleDiffPanelState implements Disposable {
return LineBlocks.EMPTY;
}
return addMarkup(new TextCompareProcessor(myComparisonPolicy, myDiffPolicy).process(myAppender1.getText(), myAppender2.getText()));
if (myHighlightMode == HighlightMode.NO_HIGHLIGHTING) {
return LineBlocks.fromLineFragments(new ArrayList<LineFragment>());
}
return addMarkup(new TextCompareProcessor(myComparisonPolicy, myDiffPolicy, myHighlightMode == HighlightMode.BY_WORD)
.process(myAppender1.getText(), myAppender2.getText()));
}
public Project getProject() { return myProject; }
@@ -32,28 +32,38 @@ public class TextCompareProcessor {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.processing.Processor");
private final DiffPolicy myDiffPolicy;
@NotNull private final ComparisonPolicy myComparisonPolicy;
private final boolean mySearchForSubFragments;
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy, final DiffPolicy diffPolicy) {
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy,
final DiffPolicy diffPolicy,
boolean searchForSubFragments) {
myComparisonPolicy = comparisonPolicy;
myDiffPolicy = diffPolicy;
mySearchForSubFragments = searchForSubFragments;
}
public TextCompareProcessor(ComparisonPolicy comparisonPolicy) {
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy, final DiffPolicy diffPolicy) {
this(comparisonPolicy, diffPolicy, true);
}
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy) {
this(comparisonPolicy, DiffPolicy.LINES_WO_FORMATTING);
}
public ArrayList<LineFragment> process(String text1, String text2) throws FilesTooBigForDiffException {
DiffFragment[] woFormattingBlocks = myDiffPolicy.buildFragments(text1, text2);
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(myComparisonPolicy).
correctAndNormalize(woFormattingBlocks);
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(myComparisonPolicy).correctAndNormalize(woFormattingBlocks);
ArrayList<LineFragment> lineBlocks = new DiffFragmentsProcessor().process(step1lineFragments);
for (LineFragment lineBlock : lineBlocks) {
if (lineBlock.isOneSide() || lineBlock.isEqual()) continue;
String subText1 = lineBlock.getText(text1, FragmentSide.SIDE1);
String subText2 = lineBlock.getText(text2, FragmentSide.SIDE2);
ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
lineBlock.adjustTypeFromChildrenTypes();
if (mySearchForSubFragments) {
for (LineFragment lineBlock : lineBlocks) {
if (lineBlock.isOneSide() || lineBlock.isEqual()) continue;
String subText1 = lineBlock.getText(text1, FragmentSide.SIDE1);
String subText2 = lineBlock.getText(text2, FragmentSide.SIDE2);
ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
lineBlock.adjustTypeFromChildrenTypes();
}
}
return lineBlocks;
}
@@ -36,6 +36,7 @@ public class SyncScrollSupport implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.util.SyncScrollSupport");
private boolean myDuringVerticalScroll = false;
private final ArrayList<ScrollListener> myScrollers = new ArrayList<ScrollListener>();
private boolean myEnabled = true;
public void install(EditingSides[] sideContainers) {
Disposer.dispose(this);
@@ -58,6 +59,14 @@ public class SyncScrollSupport implements Disposable {
myScrollers.clear();
}
public void setEnabled(boolean enabled) {
myEnabled = enabled;
}
public boolean isEnabled() {
return myEnabled;
}
private void install2(Editor[] editors, EditingSides[] sideContainers) {
addSlavesScroller(editors[0], new Pair<FragmentSide, EditingSides>(FragmentSide.SIDE1, sideContainers[0]));
addSlavesScroller(editors[1], new Pair<FragmentSide, EditingSides>(FragmentSide.SIDE2, sideContainers[0]));
@@ -100,7 +109,7 @@ public class SyncScrollSupport implements Disposable {
}
public void visibleAreaChanged(VisibleAreaEvent e) {
if (myDuringVerticalScroll) return;
if (!myEnabled || myDuringVerticalScroll) return;
Rectangle newRectangle = e.getNewRectangle();
Rectangle oldRectangle = e.getOldRectangle();
if (newRectangle == null || oldRectangle == null) return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class FileContentQueue {
private final Object myProceedWithProcessingLock = new Object();
private static final boolean ourAllowParallelFileReading = SystemProperties.getBooleanProperty("idea.allow.parallel.file.reading", true);
public void queue(final Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
public void queue(@NotNull Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
myFilesToLoadQueue.addAll(files);
final Runnable contentLoadingRunnable = new Runnable() {
@Override
@@ -38,6 +38,7 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
myTextField.setName(NAME);
}
@Override
public void selectAll() {
myTextField.selectAll();
myTextField.requestFocus();
@@ -48,18 +49,22 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
return myTextField.getEditor();
}
@Override
public EditorTextField getEditorComponent() {
return myTextField;
}
@Override
public void addActionListener(ActionListener l) {
}
@Override
public void removeActionListener(ActionListener l) {
}
@Override
public Object getItem() {
return getDocument();
}
@@ -68,6 +73,7 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
return myTextField.getDocument();
}
@Override
public void setItem(Object anObject) {
myTextField.setDocument((Document)anObject);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -95,7 +95,6 @@ public class AbstractPopup implements JBPopup {
private boolean myCancelOnWindowDeactivation = true;
private Dimension myForcedSize;
private Point myForcedLocation;
private ChildFocusWatcher myFocusWatcher;
private boolean myCancelKeyEnabled;
private boolean myLocateByContent;
protected FocusTrackback myFocusTrackback;
@@ -1037,7 +1036,7 @@ public class AbstractPopup implements JBPopup {
}
myFocusWatcher = new ChildFocusWatcher(myContent) {
ChildFocusWatcher focusWatcher = new ChildFocusWatcher(myContent) {
@Override
protected void onFocusGained(final FocusEvent event) {
setWindowActive(true);
@@ -1047,8 +1046,8 @@ public class AbstractPopup implements JBPopup {
protected void onFocusLost(final FocusEvent event) {
setWindowActive(false);
}
};
Disposer.register(this, focusWatcher);
mySpeedSearchPatternField = new JTextField();
if (SystemInfo.isMac) {
@@ -1058,7 +1057,7 @@ public class AbstractPopup implements JBPopup {
}
private Window updateMaskAndAlpha(Window window) {
if (window == null) return window;
if (window == null) return null;
final WindowManagerEx wndManager = getWndManager();
if (wndManager == null) return window;
@@ -1249,11 +1248,6 @@ public class AbstractPopup implements JBPopup {
}
myMouseOutCanceller = null;
if (myFocusWatcher != null) {
myFocusWatcher.dispose();
myFocusWatcher = null;
}
resetWindow();
if (myFinalRunnable != null) {
@@ -175,4 +175,5 @@ This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP Pro
This JVM property is old and its usage is not recommended by Oracle.\n\
\n(Note: It could have been assigned by some code dynamically.)
label.proxy.exceptions.text=Example\: *.domain.com, 192.168.*
checkbox.automatic.proxy.configuration.url=Automatic proxy configuration URL\:
checkbox.automatic.proxy.configuration.url=Automatic proxy configuration URL\:
diff.acton.highlight.mode.action.name=Highlighting Mode
@@ -83,3 +83,7 @@ diff.content.selected.value=Selected Value
diff.clipboard.vs.value.dialog.title=Clipboard vs Selected Value
diff.can.not.show.unknown=Can not show diff for unknown file type
diff.acton.highlight.mode.action.by.word=By Word
diff.acton.highlight.mode.action.by.line=By Line
diff.acton.highlight.mode.action.no.highlighting=No Highlighting
diff.acton.highlight.mode.not.available.action.name=<Not available>
@@ -550,6 +550,8 @@
<reference ref="NextDiff"/>
<separator/>
<action id="Diff.IgnoreWhitespace" class="com.intellij.openapi.diff.actions.IgnoreWhiteSpacesAction" text=""/>
<separator/>
<action id="Diff.HighlightMode" class="com.intellij.openapi.diff.actions.HighlightModeAction" text=""/>
</group>
<group id="ChangeScheme">
@@ -0,0 +1,20 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.diff.impl.processing;
public enum HighlightMode {
BY_WORD, BY_LINE, NO_HIGHLIGHTING
}
@@ -15,6 +15,10 @@
*/
package com.intellij.openapi.util;
/**
* Throw this exception from {@link JDOMExternalizable#writeExternal(org.jdom.Element)} method if you don't want to store any settings.
* If you simply return from the method empty '<component name=... />' tag will be written leading to unneeded modification of configuration files.
*/
public class WriteExternalException extends Exception {
public WriteExternalException() {
super();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,28 +18,26 @@ package com.intellij.util.containers;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.RandomAccess;
import java.util.Set;
public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAccess {
// have to extend ArrayList because otherwise the spliterator() methods declared in Set and List are in conflict
public class OrderedSet<T> extends ArrayList<T> implements Set<T>, RandomAccess {
private final OpenTHashSet<T> myHashSet;
private final ArrayList<T> myElements;
public OrderedSet() {
this(ContainerUtil.<T>canonicalStrategy());
}
public OrderedSet(TObjectHashingStrategy<T> hashingStrategy) {
public OrderedSet(@NotNull TObjectHashingStrategy<T> hashingStrategy) {
this(hashingStrategy, 4);
}
public OrderedSet(TObjectHashingStrategy<T> hashingStrategy, int capacity) {
public OrderedSet(@NotNull TObjectHashingStrategy<T> hashingStrategy, int capacity) {
super(capacity);
myHashSet = new OpenTHashSet<T>(capacity, hashingStrategy);
myElements = new ArrayList<T>(capacity);
}
@Override
public int size() {
return myElements.size();
}
@Override
@@ -50,7 +48,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public boolean add(T o) {
if (myHashSet.add(o)){
myElements.add(o);
super.add(o);
return true;
}
return false;
@@ -59,7 +57,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public boolean remove(Object o) {
if (myHashSet.remove(o)){
myElements.remove(o);
super.remove(o);
return true;
}
return false;
@@ -68,19 +66,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public void clear() {
myHashSet.clear();
myElements.clear();
}
@NotNull
@Override
public Object[] toArray() {
return myElements.toArray();
}
@NotNull
@Override
public <T> T[] toArray(@NotNull T[] a) {
return myElements.toArray(a);
super.clear();
}
@Override
@@ -88,11 +74,6 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
throw new UnsupportedOperationException();
}
@Override
public T get(final int index) {
return myElements.get(index);
}
@Override
public T set(final int index, final T element) {
final T removed = remove(index);
@@ -103,13 +84,13 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public void add(final int index, final T element) {
if (myHashSet.add(element)){
myElements.add(index, element);
super.add(index, element);
}
}
@Override
public T remove(final int index) {
final T t = myElements.remove(index);
final T t = super.remove(index);
myHashSet.remove(t);
return t;
}
@@ -117,24 +98,12 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public int indexOf(final Object o) {
final int index = myHashSet.index((T)o);
return index >= 0? myElements.indexOf(myHashSet.get(index)) : -1;
return index >= 0? super.indexOf(myHashSet.get(index)) : -1;
}
@Override
public int lastIndexOf(final Object o) {
final int index = myHashSet.index((T)o);
return index >= 0 ? myElements.lastIndexOf(myHashSet.get(index)) : -1;
}
@NotNull
@Override
public ListIterator<T> listIterator() {
return myElements.listIterator();
}
@NotNull
@Override
public ListIterator<T> listIterator(final int index) {
return myElements.listIterator(index);
return index >= 0 ? super.lastIndexOf(myHashSet.get(index)) : -1;
}
}
@@ -356,9 +356,9 @@ public class UIUtil {
public static void setEnabled(Component component, boolean enabled, boolean recursively) {
component.setEnabled(enabled);
if (component instanceof JComboBox) {
if (component instanceof JComboBox && isUnderAquaLookAndFeel()) {
// On Mac JComboBox instances have children: com.apple.laf.AquaComboBoxButton and javax.swing.CellRendererPane.
// Disabling these children results in ugly UI. See WEB-10733
// Disabling these children results in ugly UI: WEB-10733
return;
}
if (component instanceof JLabel) {
@@ -809,6 +809,8 @@ public class XmlSerializerTest extends TestCase {
public int COUNT = 3;
@Attribute("name")
public String name = "James";
@Attribute("occupation")
public String occupation;
}
public void testBeanWithPrimitivePropertyBoundToAttribute() {
final BeanWithPropertiesBoundToAttribute bean = new BeanWithPropertiesBoundToAttribute();
@@ -851,7 +853,7 @@ public class XmlSerializerTest extends TestCase {
bean.STRING_V = "skip";
assertSerializer(bean, "<BeanWithPropertyFilter />", "Serialization failure", null);
assertSerializer(bean, "<BeanWithPropertyFilter />", null);
}
public static class BeanWithJDOMElement {
@@ -1145,13 +1147,13 @@ public class XmlSerializerTest extends TestCase {
}
//---------------------------------------------------------------------------------------------------
private static void assertSerializer(Object bean, String expected, SerializationFilter filter) {
assertSerializer(bean, expected, "Serialization failure", filter);
private static Element assertSerializer(Object bean, String expected, SerializationFilter filter) {
return assertSerializer(bean, expected, "Serialization failure", filter);
}
private static Object doSerializerTest(String expectedText, Object bean) {
try {
Element element = assertSerializer(bean, expectedText, "Serialization failure", null);
Element element = assertSerializer(bean, expectedText, null);
//test deserializer
@@ -37,6 +37,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull private final Project myProject;
@NotNull private final ProjectRootManager myProjectManager;
@NotNull private final ProjectLevelVcsManager myVcsManager;
@NotNull private final VcsRootChecker[] myCheckers;
public VcsRootDetectorImpl(@NotNull Project project,
@NotNull ProjectRootManager projectRootManager,
@@ -44,6 +45,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
myProject = project;
myProjectManager = projectRootManager;
myVcsManager = projectLevelVcsManager;
myCheckers = Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME);
}
@NotNull
@@ -53,7 +55,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull
public Collection<VcsRoot> detect(@Nullable VirtualFile startDir) {
if (startDir == null) {
if (startDir == null || myCheckers.length == 0) {
return Collections.emptyList();
}
@@ -140,9 +142,8 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull
private List<AbstractVcs> getVcsListFor(@NotNull VirtualFile dir) {
VcsRootChecker[] checkers = Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME);
List<AbstractVcs> vcsList = new ArrayList<AbstractVcs>();
for (VcsRootChecker checker : checkers) {
for (VcsRootChecker checker : myCheckers) {
if (checker.isRoot(dir.getPath())) {
vcsList.add(myVcsManager.findVcsByName(checker.getSupportedVcs().getName()));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -322,7 +322,7 @@ public class XDebugSessionImpl implements XDebugSession {
return myValueMarkers;
}
private static <B extends XBreakpoint<?>> XBreakpointType<?, ?> getBreakpointTypeClass(final XBreakpointHandler<B> handler) {
private static XBreakpointType getBreakpointTypeClass(final XBreakpointHandler handler) {
return XDebuggerUtil.getInstance().findBreakpointType(handler.getBreakpointTypeClass());
}
@@ -262,9 +262,13 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
@Override
@Nullable
public PsiElement findContextElement(@NotNull VirtualFile virtualFile, int offset, @NotNull Project project, boolean checkXml) {
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (file == null || document == null) {
PsiFile file = document == null ? null : PsiManager.getInstance(project).findFile(virtualFile);
if (file == null) {
return null;
}
@@ -60,6 +60,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
return myComboBox;
}
@Override
public JComponent getComponent() {
return myComboBox;
}
@@ -70,7 +71,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
public JComponent getEditorComponent() {
return (JComponent)myEditor.getEditorComponent();
return myEditor.getEditorComponent();
}
public void setEnabled(boolean enable) {
@@ -89,13 +90,12 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
private void initEditor() {
myEditor = new EditorComboBoxEditor(getProject(), myDebuggerEditorsProvider.getFileType()) {
@Override
public void setItem(Object anObject) {
if (anObject == null) {
anObject = "";
}
super.setItem(createDocument((String)anObject));
super.setItem(createDocument(StringUtil.notNullize((String)anObject)));
}
@Override
public Object getItem() {
return ((Document)super.getItem()).getText();
}
@@ -106,6 +106,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
@Override
protected void onHistoryChanged() {
fillComboBox();
}
@@ -120,6 +121,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
}
@Override
protected void doSetText(String text) {
if (myComboBox.getItemCount() > 0) {
myComboBox.setSelectedIndex(0);
@@ -133,15 +135,18 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
}
@Override
public String getText() {
final Object value = myComboBox.isPopupVisible() ? myComboBox.getPopup().getList().getSelectedValue() : myEditor.getItem();
return StringUtil.notNullize((String)value);
}
@Override
public JComponent getPreferredFocusedComponent() {
return (JComponent)myComboBox.getEditor().getEditorComponent();
}
@Override
public void selectAll() {
myComboBox.getEditor().selectAll();
}
@@ -178,7 +178,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
}
private static boolean doInjectInJava(final Project project,
final PsiElement psiElement,
@NotNull final PsiElement psiElement,
PsiLanguageInjectionHost host,
final String languageId) {
final PsiElement target = ContextComputationProcessor.getTopLevelInjectionTarget(psiElement);
@@ -245,7 +245,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
return false;
}
new WriteCommandAction(modifierListOwner.getProject(), modifierListOwner.getContainingFile()) {
protected void run(final Result result) throws Throwable {
protected void run(@NotNull final Result result) throws Throwable {
JVMElementFactory factory = JVMElementFactories.getFactory(modifierListOwner.getLanguage(), modifierListOwner.getProject());
if (factory == null) {
factory = JavaPsiFacade.getElementFactory(modifierListOwner.getProject());
@@ -484,7 +484,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
}
}
}
else {
// else {
// todo tbd
//for (InjectionPlace place : injection.getInjectionPlaces()) {
// final Matcher matcher = pattern.matcher(place.getText());
@@ -492,7 +492,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
//
// }
//}
}
// }
result.setMethodInfos(infos);
result.generatePlaces();
return result;
@@ -110,22 +110,16 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
for (VirtualFile root : GitUtil.gitRoots(Arrays.asList(filesToCheckin))) {
VirtualFile mergeMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_MERGE_MSG);
VirtualFile squashMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_SQUASH_MSG);
VirtualFile normalMsg = root.findFileByRelativePath(GitRepositoryFiles.GIT_COMMIT_EDITMSG);
try {
if (mergeMsg == null && squashMsg == null && normalMsg == null) {
if (mergeMsg == null && squashMsg == null) {
continue;
}
String encoding = GitConfigUtil.getCommitEncoding(myProject, root);
if (mergeMsg != null) {
messages.add(loadMessage(mergeMsg, encoding));
}
else if (squashMsg != null) {
messages.add(loadMessage(squashMsg, encoding));
}
else {
messages.add(loadMessage(normalMsg, encoding));
messages.add(loadMessage(squashMsg, encoding));
}
}
catch (IOException e) {
+1
View File
@@ -35,6 +35,7 @@
<root url="jar://$MODULE_DIR$/lib/gradle-build-init-1.9.jar!/" />
<root url="jar://$MODULE_DIR$/lib/gradle-native-1.9.jar!/" />
<root url="jar://$MODULE_DIR$/lib/gradle-ide-1.9.jar!/" />
<root url="jar://$MODULE_DIR$/lib/gradle-reporting-1.9.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
Binary file not shown.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -187,8 +187,9 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
catch (UnsupportedVersionException unsupportedVersionException) {
// Old gradle distribution version used (before ver. 1.8)
// fallback to use ModelBuilder gradle tooling API
Class<? extends IdeaProject> aClass = resolverCtx.isPreviewMode() ? BasicIdeaProject.class : IdeaProject.class;
ModelBuilder<? extends IdeaProject> modelBuilder = myHelper.getModelBuilder(
resolverCtx.isPreviewMode() ? BasicIdeaProject.class : IdeaProject.class,
aClass,
resolverCtx.getExternalSystemTaskId(),
resolverCtx.getSettings(),
resolverCtx.getConnection(),
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,8 @@ public class ProjectImportAction implements BuildAction<ProjectImportAction.AllM
@Nullable
@Override
public AllModels execute(final BuildController controller) {
final IdeaProject ideaProject = controller.getModel(myIsPreviewMode ? BasicIdeaProject.class : IdeaProject.class);
Class<? extends IdeaProject> aClass1 = myIsPreviewMode ? BasicIdeaProject.class : IdeaProject.class;
final IdeaProject ideaProject = controller.getModel(aClass1);
if (ideaProject == null || ideaProject.getModules().isEmpty()) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,40 +58,18 @@ public class AlignmentProvider {
}
if (myAlignments.containsKey(set2)) {
for (Iterator<PsiElement> iterator = set1.iterator(); iterator.hasNext(); ) {
PsiElement element = iterator.next();
iterator.remove();
addInternal(set2, element);
}
addSet(set1, set2);
}
else {
set1.addAll(set2);
for (Iterator<PsiElement> iterator = set2.iterator(); iterator.hasNext(); ) {
PsiElement element = iterator.next();
iterator.remove();
addInternal(set1, element);
}
addSet(set2, set1);
}
}
else if (set1 != null) {
if (allowBackwardShift != null) {
assert myAllowBackwardShift.get(set1).booleanValue() == allowBackwardShift.booleanValue();
}
if (anchor != null) {
assert myAnchor.get(set1) == anchor;
}
addInternal(set1, e2);
addElement(e2, allowBackwardShift, anchor, set1);
}
else if (set2 != null) {
if (allowBackwardShift != null) {
assert(myAllowBackwardShift.get(set2).booleanValue() == allowBackwardShift.booleanValue());
}
if (anchor != null) {
assert(myAnchor.get(set2) == anchor);
}
addInternal(set2, e1);
addElement(e1, allowBackwardShift, anchor, set2);
}
else {
final HashSet<PsiElement> set = createHashSet();
@@ -102,6 +80,25 @@ public class AlignmentProvider {
}
}
private void addElement(PsiElement e, Boolean allowBackwardShift, Alignment.Anchor anchor, Set<PsiElement> set) {
if (allowBackwardShift != null) {
assert myAllowBackwardShift.get(set).booleanValue() == allowBackwardShift.booleanValue();
}
if (anchor != null) {
assert myAnchor.get(set) == anchor;
}
addInternal(set, e);
}
private void addSet(Set<PsiElement> set1, Set<PsiElement> set2) {
for (Iterator<PsiElement> iterator = set1.iterator(); iterator.hasNext(); ) {
PsiElement element = iterator.next();
iterator.remove();
addInternal(set2, element);
}
}
private void addInternal(@NotNull Set<PsiElement> set, @NotNull PsiElement element) {
myTree.put(element, set);
set.add(element);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -301,12 +301,20 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
if (myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION) {
final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi;
final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
aligner.append(conditional.getCondition());
final AlignmentProvider.Aligner exprAligner = myAlignmentProvider.createAligner(false);
exprAligner.append(conditional.getCondition());
if (!(conditional instanceof GrElvisExpression)) {
aligner.append(conditional.getThenBranch());
exprAligner.append(conditional.getThenBranch());
}
exprAligner.append(conditional.getElseBranch());
ASTNode question = conditional.getNode().findChildByType(GroovyTokenTypes.mQUESTION);
ASTNode colon = conditional.getNode().findChildByType(GroovyTokenTypes.mCOLON);
if (question != null && colon != null) {
AlignmentProvider.Aligner questionColonAligner = myAlignmentProvider.createAligner(false);
questionColonAligner.append(question.getPsi());
questionColonAligner.append(colon.getPsi());
}
aligner.append(conditional.getElseBranch());
}
}
@@ -508,7 +516,6 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
return blockPsi instanceof GrParameterList && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS ||
blockPsi instanceof GrExtendsClause && myContext.getSettings().ALIGN_MULTILINE_EXTENDS_LIST ||
blockPsi instanceof GrThrowsClause && myContext.getSettings().ALIGN_MULTILINE_THROWS_LIST ||
blockPsi instanceof GrConditionalExpression && myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION ||
blockPsi instanceof GrListOrMap && myContext.getGroovySettings().ALIGN_MULTILINE_LIST_OR_MAP;
}
@@ -516,7 +523,6 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
return blockPsi instanceof GrParameterList ||
blockPsi instanceof GrArgumentList ||
blockPsi instanceof GrAssignmentExpression ||
blockPsi instanceof GrConditionalExpression ||
blockPsi instanceof GrExtendsClause ||
blockPsi instanceof GrThrowsClause ||
blockPsi instanceof GrListOrMap;
@@ -370,27 +370,27 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
@Override
public void visitFile(GroovyFileBase file) {
if (isAfterElementOrSemi(PACKAGE_DEFINITION)) {
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
else if (myType2 == PACKAGE_DEFINITION) {
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
else if (isLeftOrRight(TYPE_DEFINITION_TYPES)) {
if (myType1 == GROOVY_DOC_COMMENT) {
createLF(true);
}
else {
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AROUND_CLASS + 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AROUND_CLASS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
}
else if (isAfterElementOrSemi(IMPORT_STATEMENT) && myType2 != IMPORT_STATEMENT) { //after imports
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_IMPORTS + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_IMPORTS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
else if (myType1 != IMPORT_STATEMENT && !isSemiAfter(IMPORT_STATEMENT) && myType2 == IMPORT_STATEMENT) { //before imports
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_IMPORTS, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_IMPORTS, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
else if (isAfterElementOrSemi(IMPORT_STATEMENT) && myType2 == IMPORT_STATEMENT) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
else {
processClassMembers(null);
@@ -582,7 +582,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
@Override
public void visitTypeArgumentList(GrTypeArgumentList typeArgumentList) {
if (myType1 == mLT || myType2 == mGT) {
createSpaceProperty(false, true, 1);
createSpaceInCode(false);
}
}
@@ -858,7 +858,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
}
private void createLazySpace() {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
public void visitDocTag(GrDocTag docTag) {
@@ -1021,11 +1021,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
}
private void createSpaceInCode(final boolean space) {
createSpaceProperty(space, keepBlankLines());
}
private void createSpaceProperty(boolean space, int keepBlankLines) {
createSpaceProperty(space, mySettings.KEEP_LINE_BREAKS, keepBlankLines);
createSpaceProperty(space, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
}
private void createSpaceProperty(boolean space, boolean keepLineBreaks, final int keepBlankLines) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -270,7 +270,7 @@ public class GroovyIntroduceParameterMethodUsagesProcessor implements IntroduceP
@NotNull Project project) {
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
final String typeText = forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? null : forcedType.getCanonicalText();
final String typeText = forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || forcedType == PsiType.NULL ? null : forcedType.getCanonicalText();
GrParameter parameter = factory.createParameter(parameterName, typeText, parametersOwner);
parameter.getModifierList().setModifierProperty(PsiModifier.FINAL, isFinal);
@@ -713,6 +713,15 @@ print abc ?:
'''
}
void testConditional2() {
groovySettings.ALIGN_MULTILINE_TERNARY_OPERATION = true
checkFormatting('''\
print abc ? cde
:xyz''', '''\
print abc ? cde
: xyz''')
}
void testLabelsInBasicMode() {
groovySettings.indentOptions.INDENT_SIZE = 4
groovySettings.indentOptions.LABEL_INDENT_SIZE = -2
@@ -770,6 +779,8 @@ def foo() {
void testSpreadArg() { doTest() }
void testExtraLines() { doTest() }
void testLabelWithDescription() {
GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class)
CommonCodeStyleSettings commonSettings = myTempSettings.getCommonSettings(GroovyFileType.GROOVY_LANGUAGE)
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -356,6 +356,25 @@ class X {
print new X(2) {
}
''')
}
void testNullType() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, null, false, '''\
def foo() {
def a = '4'
<selection>print a</selection>
}
foo()
''', '''\
def foo(anObject) {
def a = '4'
anObject
}
foo(print(a))
''')
}
}
@@ -0,0 +1,14 @@
package abc
print 1
-----
package abc
print 1
@@ -52,8 +52,8 @@ hg4idea.configuration.executable.error=\"{0}\" doesn''t appear to be a valid hg
hg4idea.configuration.test.label=Test
hg4idea.configuration.test=&Test
hg4idea.unable.to.run.hg=Unable to run hg: {0}
hg4idea.run.success.title=Hg executed successfully
hg4idea.run.failed.title=Hg execution failed
hg4idea.run.success.title=Hg Executed Successfully
hg4idea.run.failed.title=Hg Execution Failed
hg4idea.command.executable.error=Error executing \"{0}\". Make sure you have setup the right executable in Mercurial configuration
@@ -32,7 +32,7 @@ public class HgBranchesAction extends HgAbstractGlobalAction {
@Override
protected void execute(@NotNull Project project, @NotNull Collection<VirtualFile> repositories, @Nullable VirtualFile selectedRepo) {
HgRepository repository;
HgRepository repository = null;
if (selectedRepo != null) {
repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(selectedRepo);
}
@@ -41,9 +41,6 @@ public class HgBranchesAction extends HgAbstractGlobalAction {
if (selectedRoot != null) {
repository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(selectedRoot);
}
else {
return;
}
}
if (repository != null) {
HgBranchPopup.getInstance(project, repository).asListPopup().showInFocusCenter();
@@ -353,7 +353,7 @@ public abstract class HgUtil {
//get file name in target revision if it was moved/renamed
HgStatusCommand statCommand = new HgStatusCommand.Builder(false).copySource(true).baseRevision(vcsRevisionNumber).build(project);
Set<HgChange> changes = statCommand.execute(localHgFile.getRepo(), Arrays.asList(localHgFile.toFilePath()));
Set<HgChange> changes = statCommand.execute(localHgFile.getRepo(), Collections.singletonList(localHgFile.toFilePath()));
for (HgChange change : changes) {
if (change.afterFile().equals(localHgFile)) {
@@ -70,10 +70,7 @@ public final class HgVersion implements Comparable<HgVersion> {
@NotNull private final Set<String> myUnsupportedExtensions;
public HgVersion(int major, int middle, int minor) {
myMajor = major;
myMiddle = middle;
myMinor = minor;
myUnsupportedExtensions = Collections.emptySet();
this(major, middle, minor, Collections.<String>emptySet());
}
public HgVersion(int major, int middle, int minor, @NotNull Set<String> unsupportedExtensions) {
Binary file not shown.
@@ -27,6 +27,7 @@ public class SceneBuilderImpl implements SceneBuilder {
private final JFXPanel myPanel = new JFXPanel();
private EditorController myEditorController;
private ChangeListener<Number> myListener;
private volatile boolean mySkipChanges;
public SceneBuilderImpl(URL url, EditorCallback editorCallback) {
myFileURL = url;
@@ -88,7 +89,9 @@ public class SceneBuilderImpl implements SceneBuilder {
myListener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
myEditorCallback.saveChanges(myEditorController.getFxmlText());
if (!mySkipChanges) {
myEditorCallback.saveChanges(myEditorController.getFxmlText());
}
}
};
@@ -103,6 +106,8 @@ public class SceneBuilderImpl implements SceneBuilder {
}
private void loadFile() {
mySkipChanges = true;
try {
String fxmlText = FXOMDocument.readContentFromURL(myFileURL);
myEditorController.setFxmlTextAndLocation(fxmlText, myFileURL);
@@ -110,5 +115,8 @@ public class SceneBuilderImpl implements SceneBuilder {
catch (Throwable e) {
myEditorCallback.handleError(e);
}
finally {
mySkipChanges = false;
}
}
}
@@ -57,6 +57,7 @@
<actions>
<action class="org.jetbrains.plugins.javaFX.actions.OpenInSceneBuilderAction" id="OpenInSceneBuilder" text="Open In SceneBuilder">
<add-to-group group-id="EditorPopupMenu" anchor="last"/>
<add-to-group group-id="EditorTabPopupMenu" anchor="last"/>
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
</action>
</actions>
@@ -17,35 +17,18 @@ package org.jetbrains.plugins.javaFX.actions;
import com.intellij.CommonBundle;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.PathEnvironmentVariableUtil;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.JavaFxSettings;
import org.jetbrains.plugins.javaFX.JavaFxSettingsConfigurable;
import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderInfo;
/**
* User: anna
@@ -53,84 +36,21 @@ import java.util.List;
*/
public class OpenInSceneBuilderAction extends AnAction {
private static final Logger LOG = Logger.getInstance("#" + OpenInSceneBuilderAction.class.getName());
public static final String ORACLE = "Oracle";
@Override
public void actionPerformed(AnActionEvent e) {
final VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
LOG.assertTrue(virtualFile != null);
final String path = virtualFile.getPath();
final JavaFxSettings settings = JavaFxSettings.getInstance();
String pathToSceneBuilder = settings.getPathToSceneBuilder();
if (StringUtil.isEmptyOrSpaces(settings.getPathToSceneBuilder())){
final VirtualFile sceneBuilderFile = FileChooser.chooseFile(JavaFxSettingsConfigurable.createSceneBuilderDescriptor(), e.getProject(), getPredefinedPath());
if (sceneBuilderFile == null) return;
pathToSceneBuilder = sceneBuilderFile.getPath();
settings.setPathToSceneBuilder(FileUtil.toSystemIndependentName(pathToSceneBuilder));
}
final Project project = getEventProject(e);
if (project != null && !Registry.is("scene.builder.start.executable", true)) {
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
if (module != null) {
try {
final JavaParameters javaParameters = new JavaParameters();
javaParameters.configureByModule(module, JavaParameters.JDK_AND_CLASSES);
final File sceneBuilderLibsFile;
if (SystemInfo.isMac) {
sceneBuilderLibsFile = new File(new File(pathToSceneBuilder, "Contents"), "Java");
} else if (SystemInfo.isWindows) {
File sceneBuilderRoot = new File(pathToSceneBuilder);
File sceneBuilderRootDir = sceneBuilderRoot.getParentFile();
if (sceneBuilderRootDir == null) {
final File foundInPath = PathEnvironmentVariableUtil.findInPath(pathToSceneBuilder);
if (foundInPath != null) {
sceneBuilderRootDir = foundInPath.getParentFile();
}
}
sceneBuilderRoot = sceneBuilderRootDir != null ? sceneBuilderRootDir.getParentFile() : null;
if (sceneBuilderRoot != null) {
final File libFile = new File(sceneBuilderRoot, "lib");
if (libFile.isDirectory()) {
sceneBuilderLibsFile = libFile;
}
else {
final File appFile = new File(sceneBuilderRootDir, "app");
sceneBuilderLibsFile = appFile.isDirectory() ? appFile : null;
}
}
else {
sceneBuilderLibsFile = null;
}
} else {
sceneBuilderLibsFile = new File(new File(pathToSceneBuilder).getParent(), "app");
}
if (sceneBuilderLibsFile != null) {
final File[] sceneBuilderLibs = sceneBuilderLibsFile.listFiles();
if (sceneBuilderLibs != null) {
for (File jarFile : sceneBuilderLibs) {
javaParameters.getClassPath().add(jarFile.getPath());
}
javaParameters.setMainClass("com.oracle.javafx.authoring.Main");
javaParameters.getProgramParametersList().add(path);
final OSProcessHandler processHandler = javaParameters.createOSProcessHandler();
final String commandLine = processHandler.getCommandLine();
LOG.info("scene builder command line: " + commandLine);
processHandler.startNotify();
return;
}
}
}
catch (Throwable ex) {
LOG.info(ex);
}
}
final SceneBuilderInfo info = SceneBuilderInfo.get(project, true);
if (info == SceneBuilderInfo.EMPTY) {
return;
}
String pathToSceneBuilder = info.path;
if (SystemInfo.isMac) {
pathToSceneBuilder += "/Contents/MacOS/scenebuilder-launcher.sh";
}
@@ -152,45 +72,11 @@ public class OpenInSceneBuilderAction extends AnAction {
presentation.setEnabled(false);
presentation.setVisible(false);
final VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
if (virtualFile != null &&
if (virtualFile != null &&
JavaFxFileTypeFactory.isFxml(virtualFile) &&
e.getProject() != null) {
presentation.setEnabled(true);
presentation.setVisible(true);
}
}
@Nullable
private static VirtualFile getPredefinedPath() {
String path = null;
if (SystemInfo.isWindows) {
final String sb11 = File.separator + "JavaFX Scene Builder 1.1" + File.separator + "JavaFX Scene Builder 1.1.exe";
final String sb10 = File.separator + "JavaFX Scene Builder 1.0" + File.separator + "bin" + File.separator + "scenebuilder.exe";
final List<String> suspiciousPaths = new ArrayList<String>();
final String programFiles = "C:\\Program Files";
fillPaths(programFiles, sb11, sb10, suspiciousPaths);
fillPaths(programFiles + " (x86)", sb11, sb10, suspiciousPaths);
final File sb = FileUtil.findFirstThatExist(ArrayUtil.toStringArray(suspiciousPaths));
if (sb != null) {
path = sb.getPath();
}
}
else if (SystemInfo.isMac) {
final File sb = FileUtil.findFirstThatExist("/Applications/JavaFX Scene Builder 1.1.app",
"/Applications/JavaFX Scene Builder 1.0.app");
if (sb != null) {
path = sb.getPath();
}
}
else if (SystemInfo.isUnix) {
path = "/opt/JavaFXSceneBuilder1.1/JavaFXSceneBuilder1.1";
}
return path != null ? LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(path)) : null;
}
private static void fillPaths(String programFilesPath, String sb11, String sb10, List<String> suspiciousPaths) {
suspiciousPaths.add(new File(programFilesPath, ORACLE).getPath() + sb11);
suspiciousPaths.add(new File(programFilesPath, ORACLE).getPath() + sb10);
}
}
@@ -61,8 +61,7 @@ public class GenericRepositoryType extends BaseRepositoryType<GenericRepository>
this,
new AsanaRepository(),
new AssemblaRepository(),
new SprintlyRepository(),
new GitlabRepository()
new SprintlyRepository()
);
}
@@ -127,10 +126,4 @@ public class GenericRepositoryType extends BaseRepositoryType<GenericRepository>
super("Sprintly", TasksIcons.Sprintly);
}
}
public final class GitlabRepository extends GenericSubtype {
public GitlabRepository() {
super("Gitlab", TasksIcons.Gitlab);
}
}
}
@@ -1,75 +0,0 @@
<Generic shared="false" url="">
<commitMessageFormat>{id} {summary}</commitMessageFormat>
<option name="downloadTasksInSeparateRequests" value="false" />
<password />
<option name="loginAnonymously" value="true" />
<option name="loginMethodType" value="GET" />
<option name="loginUrl" value="" />
<option name="responseHandlers">
<XPathResponseHandler>
<selectors>
<selector name="tasks" path="" />
<selector name="id" path="" />
<selector name="summary" path="" />
<selector name="description" path="" />
<selector name="updated" path="" />
<selector name="created" path="" />
<selector name="closed" path="" />
<selector name="issueUrl" path="" />
<selector name="singleTask-id" path="" />
<selector name="singleTask-summary" path="" />
<selector name="singleTask-description" path="" />
<selector name="singleTask-updated" path="" />
<selector name="singleTask-created" path="" />
<selector name="singleTask-closed" path="" />
<selector name="singleTask-issueUrl" path="" />
</selectors>
</XPathResponseHandler>
<JsonResponseHandler>
<selectors>
<selector name="tasks" path="[*]" />
<selector name="id" path="id" />
<selector name="summary" path="title" />
<selector name="description" path="description" />
<selector name="updated" path="updated_at" />
<selector name="created" path="created_at" />
<selector name="closed" path="" />
<selector name="issueUrl" path="" />
<selector name="singleTask-id" path="id" />
<selector name="singleTask-summary" path="title" />
<selector name="singleTask-description" path="description" />
<selector name="singleTask-updated" path="updated_at" />
<selector name="singleTask-created" path="created_at" />
<selector name="singleTask-closed" path="" />
<selector name="singleTask-issueUrl" path="" />
</selectors>
</JsonResponseHandler>
<RegExResponseHandler>
<option name="taskRegex" value="" />
</RegExResponseHandler>
</option>
<option name="responseType" value="JSON" />
<option name="shouldFormatCommitMessage" value="false" />
<option name="singleTaskMethodType" value="GET" />
<option name="singleTaskUrl" value="{serverUrl}/api/v3/projects/{project_ID}/issues?private_token={token}" />
<option name="subtypeName" />
<option name="tasksListMethodType" value="GET" />
<option name="tasksListUrl" value="{serverUrl}/api/v3/projects/{project_ID}/issues?private_token={token}" />
<option name="templateVariables">
<list>
<TemplateVariable hidden="true" readOnly="false" shownOnFirstTab="true">
<option name="description" value="" />
<option name="name" value="token" />
<option name="value" value="" />
</TemplateVariable>
<TemplateVariable hidden="false" readOnly="false" shownOnFirstTab="true">
<option name="description" value="" />
<option name="name" value="project_ID" />
<option name="value" value="" />
</TemplateVariable>
</list>
</option>
<option name="useHttpAuthentication" value="false" />
<option name="useProxy" value="false" />
<username />
</Generic>
@@ -1,129 +0,0 @@
package com.intellij.tasks.integration;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskTestUtil;
import com.intellij.tasks.generic.GenericRepository;
import com.intellij.tasks.generic.GenericRepositoryType;
import org.jetbrains.annotations.NotNull;
/**
* @author Mikhail Golubev
*/
public class GitlabIntegrationTest extends GenericSubtypeTestCase {
private static final String TASK_LIST_RESPONSE = "[\n" +
" {\n" +
" \"id\": 2,\n" +
" \"iid\": 2,\n" +
" \"project_id\": 1,\n" +
" \"title\": \"Drink more tea\",\n" +
" \"description\": \"It\\u0027s healthy.\",\n" +
" \"labels\": [],\n" +
" \"assignee\": {\n" +
" \"id\": 4,\n" +
" \"username\": \"deva\",\n" +
" \"email\": \"deva@somemail.com\",\n" +
" \"name\": \"John Smith\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:34:37Z\"\n" +
" },\n" +
" \"author\": {\n" +
" \"id\": 1,\n" +
" \"username\": \"root\",\n" +
" \"email\": \"admin@local.host\",\n" +
" \"name\": \"Administrator\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:19:43Z\"\n" +
" },\n" +
" \"state\": \"opened\",\n" +
" \"updated_at\": \"2013-11-14T12:38:51Z\",\n" +
" \"created_at\": \"2013-11-14T12:33:07Z\"\n" +
" },\n" +
" {\n" +
" \"id\": 1,\n" +
" \"iid\": 1,\n" +
" \"project_id\": 1,\n" +
" \"title\": \"Eat more bananas\",\n" +
" \"description\": \"They're tasty.\",\n" +
" \"labels\": [\n" +
" \"spam\"\n" +
" ],\n" +
" \"assignee\": {\n" +
" \"id\": 1,\n" +
" \"username\": \"root\",\n" +
" \"email\": \"admin@local.host\",\n" +
" \"name\": \"Administrator\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:19:43Z\"\n" +
" },\n" +
" \"author\": {\n" +
" \"id\": 1,\n" +
" \"username\": \"root\",\n" +
" \"email\": \"admin@local.host\",\n" +
" \"name\": \"Administrator\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:19:43Z\"\n" +
" },\n" +
" \"state\": \"opened\",\n" +
" \"updated_at\": \"2013-11-14T12:30:39Z\",\n" +
" \"created_at\": \"2013-11-14T12:30:39Z\"\n" +
" }\n" +
"] ";
private static final String SINGLE_TASK_RESPONSE = "{\n" +
" \"id\": 2,\n" +
" \"iid\": 2,\n" +
" \"project_id\": 1,\n" +
" \"title\": \"Drink more tea\",\n" +
" \"description\": \"It\\u0027s healthy.\",\n" +
" \"labels\": [],\n" +
" \"assignee\": {\n" +
" \"id\": 4,\n" +
" \"username\": \"deva\",\n" +
" \"email\": \"deva@somemail.com\",\n" +
" \"name\": \"John Smith\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:34:37Z\"\n" +
" },\n" +
" \"author\": {\n" +
" \"id\": 1,\n" +
" \"username\": \"root\",\n" +
" \"email\": \"admin@local.host\",\n" +
" \"name\": \"Administrator\",\n" +
" \"state\": \"active\",\n" +
" \"created_at\": \"2013-11-14T12:19:43Z\"\n" +
" },\n" +
" \"state\": \"opened\",\n" +
" \"updated_at\": \"2013-11-14T12:38:51Z\",\n" +
" \"created_at\": \"2013-11-14T12:33:07Z\"\n" +
"}";
private Task getTask1() {
return new TaskTestUtil.TaskBuilder("1", "Eat more bananas", myRepository)
.withDescription("They're tasty.")
.withUpdated("2013-11-14T12:30:39Z")
.withCreated("2013-11-14T12:30:39Z");
}
private Task getTask2() {
return new TaskTestUtil.TaskBuilder("2", "Drink more tea", myRepository)
.withDescription("It's healthy.")
.withUpdated("2013-11-14T12:38:51Z")
.withCreated("2013-11-14T12:33:07Z");
}
@NotNull
@Override
protected GenericRepository createRepository(GenericRepositoryType genericType) {
return (GenericRepository)genericType.new GitlabRepository().createRepository();
}
public void testParsingTaskList() throws Exception {
Task[] tasks = myRepository.getActiveResponseHandler().parseIssues(TASK_LIST_RESPONSE, 50);
TaskTestUtil.assertTasksEqual(new Task[]{getTask2(), getTask1()}, tasks);
}
public void testParsingSingleTask() throws Exception {
Task task = myRepository.getActiveResponseHandler().parseIssue(SINGLE_TASK_RESPONSE);
TaskTestUtil.assertTasksEqual(getTask2(), task);
}
}
+1 -1
View File
@@ -116,7 +116,7 @@ class TeamcityPlugin(ErrorClassPlugin, TextTestResult, TeamcityTestResult):
suite = strclass(test.__class__)
suite_location = "python_nosetestid://" + suite
try:
from nose_helper.util import func_lineno
from nose.util import func_lineno
if hasattr(test.test, "descriptor") and test.test.descriptor:
suite_location = "file://" + self.test_address(
@@ -81,7 +81,8 @@ public class PyInjectionUtil {
*/
@NotNull
public static InjectionResult registerStringLiteralInjection(@NotNull PsiElement element, @NotNull MultiHostRegistrar registrar) {
return processStringLiteral(element, registrar, "", "", Formatting.NONE);
// Assume percent formatting since the MySQL parser cannot handle Python-style substitutions
return processStringLiteral(element, registrar, "", "", Formatting.PERCENT);
}
private static boolean isStringLiteralPart(@NotNull PsiElement element, @Nullable PsiElement context) {
@@ -238,6 +238,9 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
if (defaultValue != null) {
final PyType type = context.getType(defaultValue);
if (type != null && !(type instanceof PyNoneType)) {
if (type instanceof PyTupleType) {
return PyTypeParser.getTypeByName(this, "collections.Iterable");
}
return type;
}
}
@@ -249,15 +252,18 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
@Override
public boolean process(@NotNull PyCallExpression call) {
final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context);
final CallArgumentsMapping mapping = call.getArgumentList().analyzeCall(resolveContext);
for (Map.Entry<PyExpression, PyNamedParameter> entry : mapping.getPlainMappedParams().entrySet()) {
if (entry.getValue() == PyNamedParameterImpl.this) {
final PyExpression argument = entry.getKey();
if (argument != null) {
final PyType type = context.getType(argument);
if (type != null) {
types.add(type);
return true;
final PyArgumentList argumentList = call.getArgumentList();
if (argumentList != null) {
final CallArgumentsMapping mapping = argumentList.analyzeCall(resolveContext);
for (Map.Entry<PyExpression, PyNamedParameter> entry : mapping.getPlainMappedParams().entrySet()) {
if (entry.getValue() == PyNamedParameterImpl.this) {
final PyExpression argument = entry.getKey();
if (argument != null) {
final PyType type = context.getType(argument);
if (type != null) {
types.add(type);
return true;
}
}
}
}
@@ -22,6 +22,7 @@ import com.intellij.refactoring.classMembers.DependentMembersCollectorBase;
import com.intellij.refactoring.classMembers.MemberInfoBase;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
/**
* @author Dennis.Ushakov
@@ -139,6 +139,22 @@ public class PyClassRefactoringUtil {
return false;
}
/**
* Moves class field to another class
* @param expressions list of class fields
* @param superClass where to move them
*/
public static void moveFields(@NotNull final Collection<PyTargetExpression> expressions, @NotNull final PyClass superClass) {
for (final PyTargetExpression expression : expressions) {
final PyAssignmentStatement expAssignmentStatement = PsiTreeUtil.getParentOfType(expression, PyAssignmentStatement.class);
assert expAssignmentStatement != null: "Target expression has no assignment statement";
final PyStatementList superClassStatement = superClass.getStatementList();
PyUtil.addElementToStatementList(expAssignmentStatement.copy(), superClassStatement, true);
expAssignmentStatement.delete();
PyPsiUtils.removeRedundantPass(superClassStatement);
}
}
public static void moveMethods(Collection<PyFunction> methods, PyClass superClass) {
if (methods.size() == 0) return;
for (PsiElement e : methods) {
@@ -29,6 +29,7 @@ public class PyDependentMembersCollector extends DependentMembersCollectorBase<P
@Override
public void collect(PyElement member) {
//TODO: Move to MembersManager as well
final PyRecursiveElementVisitor visitor = new PyRecursiveElementVisitor() {
@Override
public void visitPyCallExpression(PyCallExpression node) {
@@ -1,72 +0,0 @@
/*
* Copyright 2000-2013 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.jetbrains.python.refactoring.classes;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.classMembers.MemberInfoBase;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.refactoring.classes.ui.PyClassCellRenderer;
/**
* @author Dennis.Ushakov
*/
public class PyMemberInfo extends MemberInfoBase<PyElement> {
public PyMemberInfo(PyElement member) {
super(member);
final PyClass clazz = PyUtil.getContainingClassOrSelf(member);
assert clazz != null;
if (member instanceof PyFunction) {
PyFunction function = (PyFunction)member;
displayName = buildDisplayMethodName(function);
for (PyClass aClass : clazz.getSuperClasses()) {
final PyFunction parentMethod = aClass.findMethodByName(function.getName(), true);
if (parentMethod != null) {
overrides = true;
}
}
} else if (member instanceof PyClass) {
displayName = RefactoringBundle.message("member.info.extends.0", PyClassCellRenderer.getClassText((PyClass)member));
}
}
private static String buildDisplayMethodName(PyFunction method) {
final StringBuilder builder = new StringBuilder(method.getName());
builder.append("(");
final PyParameter[] arguments = method.getParameterList().getParameters();
for (PyParameter parameter : arguments) {
builder.append(parameter.getName());
if (arguments.length > 1 && parameter != arguments[arguments.length - 1]) {
builder.append(", ");
}
}
builder.append(")");
return builder.toString();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PyMemberInfo) {
return getMember().equals(((PyMemberInfo)obj).getMember());
}
return false;
}
@Override
public int hashCode() {
return getMember().hashCode();
}
}
@@ -22,6 +22,8 @@ import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.psi.PyFunction;
import com.jetbrains.python.refactoring.PyRefactoringUtil;
import com.jetbrains.python.refactoring.classes.membersManager.MembersManager;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import java.util.ArrayList;
@@ -60,12 +62,7 @@ public class PyMemberInfoStorage extends AbstractMemberInfoStorage<PyElement, Py
@Override
protected void extractClassMembers(PyClass aClass, ArrayList<PyMemberInfo> temp) {
for (PyFunction function : aClass.getMethods()) {
temp.add(new PyMemberInfo(function));
}
for (PyClass pyClass : aClass.getSuperClasses()) {
temp.add(new PyMemberInfo(pyClass));
}
temp.addAll(MembersManager.getAllMembersCouldBeMoved(aClass));
}
@Override
@@ -34,7 +34,7 @@ import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PythonLanguage;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.PyMemberInfoStorage;
import com.jetbrains.python.refactoring.classes.ui.UpDirectedMembersMovingDialog;
import org.jetbrains.annotations.NotNull;
@@ -28,7 +28,7 @@ import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyUtil;
import com.jetbrains.python.refactoring.classes.PyClassMembersRefactoringSupport;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringHandler;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.PyMemberInfoStorage;
import java.util.Collection;
@@ -37,7 +37,7 @@ import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.PyPsiUtils;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -0,0 +1,57 @@
package com.jetbrains.python.refactoring.classes.membersManager;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.psi.PyAssignmentStatement;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.psi.PyTargetExpression;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Moves class attributes up
* @author Ilya.Kazakevich
*/
class ClassFieldsManager extends MembersManager<PyTargetExpression> {
ClassFieldsManager() {
super(PyTargetExpression.class);
}
@NotNull
@Override
protected List<PyElement> getMembersCouldBeMoved(@NotNull final PyClass pyClass) {
return new ArrayList<PyElement>(Collections2.filter(pyClass.getClassAttributes(), new SimpleAssignmentsOnly()));
}
@Override
protected void moveMembers(@NotNull final PyClass from, @NotNull final PyClass to, @NotNull final Collection<PyTargetExpression> members) {
PyClassRefactoringUtil.moveFields(members, to);
}
@NotNull
@Override
public PyMemberInfo apply(@NotNull final PyElement input) {
return new PyMemberInfo(input, true, input.getText(), false, this); //TODO: Check overrides
}
private static class SimpleAssignmentsOnly implements Predicate<PyTargetExpression> {
//Support only simplest cases like CLASS_VAR = 42.
//Tuples (CLASS_VAR_1, CLASS_VAR_2) = "spam", "eggs" are not supported by now
@Override
public boolean apply(@Nullable final PyTargetExpression input) {
if (input == null) {
return false; //Filter out empties (which probably would never be here)
}
final PsiElement parent = input.getParent();
return (parent != null) && PyAssignmentStatement.class.isAssignableFrom(parent.getClass());
}
}
}
@@ -0,0 +1,141 @@
package com.jetbrains.python.refactoring.classes.membersManager;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
import com.google.common.collect.Multimap;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Moves members between classes via its plugins (managers).
* To move members use {@link #getAllMembersCouldBeMoved(com.jetbrains.python.psi.PyClass)} and {@link #moveMembers(com.jetbrains.python.psi.PyClass, com.jetbrains.python.psi.PyClass, java.util.Collection)}
* To add new manager, extend this class and add it to {@link #MANAGERS}
*
* @author Ilya.Kazakevich
*/
public abstract class MembersManager<T extends PyElement> implements Function<PyElement, PyMemberInfo> {
/**
* List of managers. Class delegates all logic to them.
*/
private static final Collection<? extends MembersManager<?>> MANAGERS =
Arrays.asList(new MethodsManager(), new SuperClassesManager(), new ClassFieldsManager());
private static final PyMemberExtractor PY_MEMBER_EXTRACTOR = new PyMemberExtractor();
@NotNull
private final Class<T> myExpectedClass;
protected MembersManager(@NotNull final Class<T> expectedClass) {
myExpectedClass = expectedClass;
}
/**
* Get all members that could be moved out of certain class
*
* @param pyClass class to find members
* @return list of members could be moved
*/
@NotNull
public static List<PyMemberInfo> getAllMembersCouldBeMoved(@NotNull final PyClass pyClass) {
final List<PyMemberInfo> result = new ArrayList<PyMemberInfo>();
for (final MembersManager<?> manager : MANAGERS) {
result.addAll(Collections2.transform(manager.getMembersCouldBeMoved(pyClass), manager));
}
return result;
}
/**
* Moves members from one class to another
*
* @param from source
* @param to destination
* @param memberInfos members to move
*/
public static void moveAllMembers(@NotNull final PyClass from,
@NotNull final PyClass to,
@NotNull final Collection<PyMemberInfo> memberInfos) {
final Multimap<MembersManager<?>, PyMemberInfo> managerToMember = ArrayListMultimap.create();
//Collect map (manager)->(list_of_memebers)
for (final PyMemberInfo memberInfo : memberInfos) {
managerToMember.put(memberInfo.getMembersManager(), memberInfo);
}
//Move members via manager
for (final MembersManager<?> membersManager : managerToMember.keySet()) {
moveSafely(from, to, membersManager, Collections2.transform(managerToMember.get(membersManager), PY_MEMBER_EXTRACTOR));
}
PyClassRefactoringUtil.insertPassIfNeeded(from);
}
@SuppressWarnings({"unchecked", "rawtypes"}) //We check classes at runtime
private static void moveSafely(@NotNull final PyClass from,
@NotNull final PyClass to,
@NotNull final MembersManager<?> manager,
@NotNull final Collection<PyElement> elementsToMove) {
for (final PyElement pyElement : elementsToMove) {
Preconditions.checkArgument(manager.myExpectedClass.isAssignableFrom(pyElement.getClass()),
String.format("Manager %s expected %s but got %s", manager, manager.myExpectedClass, pyElement));
}
manager.moveMembers(from, to, (Collection)elementsToMove);
}
/**
* Finds member in class. It is here only for backward compatibility with some tests.
*/
//TODO: mark deprecated?
@TestOnly
@NotNull
public static PyMemberInfo findMember(@NotNull final PyClass pyClass, @NotNull final PyElement pyElement) {
for (final PyMemberInfo pyMemberInfo : getAllMembersCouldBeMoved(pyClass)) {
if (pyMemberInfo.getMember().equals(pyElement)) {
return pyMemberInfo;
}
}
throw new IllegalArgumentException(String.format("Element %s not found in class %s or can't be moved", pyElement, pyClass));
}
/**
* Get list of elements certain plugin could move out of the class
*
* @param pyClass class with members
* @return list of members
*/
@NotNull
protected abstract List<PyElement> getMembersCouldBeMoved(@NotNull PyClass pyClass);
/**
* Moves element from one class to another
*
* @param from source
* @param to destination
* @param members collection of memebrs to move
*/
protected abstract void moveMembers(@NotNull PyClass from, @NotNull PyClass to, @NotNull Collection<T> members);
//TODO: Doc
@SuppressWarnings("NullableProblems") //IDEA-120100
@NotNull
@Override
public abstract PyMemberInfo apply(@NotNull PyElement input);
private static class PyMemberExtractor implements Function<PyMemberInfo, PyElement> {
@SuppressWarnings("NullableProblems") //IDEA-120100
@Override
public PyElement apply(@NotNull final PyMemberInfo input) {
return input.getMember();
}
}
}
@@ -0,0 +1,70 @@
package com.jetbrains.python.refactoring.classes.membersManager;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Plugin that moves class methods
*
* @author Ilya.Kazakevich
*/
class MethodsManager extends MembersManager<PyFunction> {
MethodsManager() {
super(PyFunction.class);
}
@NotNull
@Override
protected List<PyElement> getMembersCouldBeMoved(@NotNull final PyClass pyClass) {
return Arrays.<PyElement>asList(pyClass.getMethods());
}
@Override
protected void moveMembers(@NotNull final PyClass from, @NotNull final PyClass to, @NotNull final Collection<PyFunction> members) {
PyClassRefactoringUtil.moveMethods(members, to);
}
@NotNull
@Override
public PyMemberInfo apply(@NotNull final PyElement input) {
//TODO: Use generics to prevent casting in each subclass
final PyFunction pyFunction = (PyFunction)input;
//TODO: Support static and classmethod functions
return new PyMemberInfo(input, false, buildDisplayMethodName(pyFunction), isOverrides(pyFunction), this);
}
@Nullable
private static Boolean isOverrides(final PyFunction pyFunction) {
final PyClass clazz = PyUtil.getContainingClassOrSelf(pyFunction);
assert clazz != null : "Refactoring called on function, not method: " + pyFunction;
for (final PyClass parentClass : clazz.getSuperClasses()) {
final PyFunction parentMethod = parentClass.findMethodByName(pyFunction.getName(), true);
if (parentMethod != null) {
return true;
}
}
return null;
}
@NotNull
private static String buildDisplayMethodName(@NotNull final PyFunction pyFunction) {
final StringBuilder builder = new StringBuilder(pyFunction.getName());
builder.append('(');
final PyParameter[] arguments = pyFunction.getParameterList().getParameters();
for (final PyParameter parameter : arguments) {
builder.append(parameter.getName());
if (arguments.length > 1 && parameter != arguments[arguments.length - 1]) {
builder.append(", ");
}
}
builder.append(')');
return builder.toString();
}
}
@@ -0,0 +1,67 @@
/*
* Copyright 2000-2013 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.jetbrains.python.refactoring.classes.membersManager;
import com.intellij.refactoring.classMembers.MemberInfoBase;
import com.jetbrains.python.psi.PyElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Dennis.Ushakov
*/
public class PyMemberInfo extends MemberInfoBase<PyElement> {
@NotNull
private final MembersManager myMembersManager;
/**
* @param member element itself
* @param isStatic is it static or not?
* @param displayName element display name
* @param overrides does it overrides something? TRUE if is overriden, FALSE if implemented, null if not implemented or overriden
* TODO: use primitive instead? "Implemeneted" has nothing to do with python duck-typing
* @param membersManager manager that knows how to handle this member
*/
PyMemberInfo(@NotNull final PyElement member,
final boolean isStatic,
@NotNull final String displayName,
@Nullable final Boolean overrides,
@NotNull final MembersManager membersManager) {
super(member);
this.isStatic = isStatic;
this.displayName = displayName;
this.overrides = overrides;
myMembersManager = membersManager;
}
@NotNull
MembersManager getMembersManager() {
return myMembersManager;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PyMemberInfo) {
return getMember().equals(((PyMemberInfo)obj).getMember());
}
return false;
}
@Override
public int hashCode() {
return getMember().hashCode();
}
}
@@ -0,0 +1,74 @@
package com.jetbrains.python.refactoring.classes.membersManager;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Sets;
import com.intellij.psi.PsiNamedElement;
import com.intellij.refactoring.RefactoringBundle;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import com.jetbrains.python.refactoring.classes.ui.PyClassCellRenderer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
/**
* Plugin that moves superclasses from one class to another
*
* @author Ilya.Kazakevich
*/
class SuperClassesManager extends MembersManager<PyClass> {
SuperClassesManager() {
super(PyClass.class);
}
private static final NameExtractor NAME_EXTRACTOR = new NameExtractor();
private static final NameFilter NAME_FILTER = new NameFilter();
@NotNull
@Override
protected List<PyElement> getMembersCouldBeMoved(@NotNull final PyClass pyClass) {
return Arrays.<PyElement>asList(pyClass.getSuperClasses());
}
@Override
protected void moveMembers(@NotNull final PyClass from, @NotNull final PyClass to, @NotNull final Collection<PyClass> members) {
final Set<String> superClassesToMove =
Sets.newHashSet(Collections2.filter(Collections2.transform(members, NAME_EXTRACTOR), NAME_FILTER));
for (final PyElement member : members) {
superClassesToMove.add(member.getName());
}
PyClassRefactoringUtil.moveSuperclasses(from, superClassesToMove, to);
//TODO: Use generics!
PyClassRefactoringUtil.insertImport(to, new ArrayList<PsiNamedElement>(members));
}
@NotNull
@Override
public PyMemberInfo apply(@NotNull final PyElement input) {
final String name = RefactoringBundle.message("member.info.extends.0", PyClassCellRenderer.getClassText((PyClass)input));
//TODO: Check for "overrides"
return new PyMemberInfo(input, false, name, false, this);
}
private static class NameExtractor implements Function<PyElement, String> {
@SuppressWarnings("NullableProblems") //We sure collection has no null
@Nullable
@Override
public String apply(@NotNull final PyElement input) {
return input.getName();
}
}
private static class NameFilter implements Predicate<String> {
@Override
public boolean apply(@Nullable final String input) {
return input != null;
}
}
}
@@ -0,0 +1,12 @@
/**
* Incapsulates knowledge about class members that could be moved to some other class.
* To use (get list of members to move or actually move them) use {@link com.jetbrains.python.refactoring.classes.membersManager.MembersManager#getAllMembersCouldBeMoved(com.jetbrains.python.psi.PyClass)}
* and {@link com.jetbrains.python.refactoring.classes.membersManager.MembersManager#moveAllMembers(com.jetbrains.python.psi.PyClass, com.jetbrains.python.psi.PyClass, java.util.Collection)}
*
* This class delegates its behaviour to its managers (some kind of plugins). There is one for each member type (one for method, one for field etc).
* You need to extend {@link com.jetbrains.python.refactoring.classes.membersManager.MembersManager} to add some. See its javadoc for more info.
*
*
* @author Ilya.Kazakevich
*/
package com.jetbrains.python.refactoring.classes.membersManager;
@@ -26,7 +26,7 @@ import com.intellij.refactoring.ui.ConflictsDialog;
import com.intellij.util.containers.MultiMap;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.ui.PyClassCellRenderer;
import com.jetbrains.python.refactoring.classes.ui.PyMemberSelectionPanel;
import com.jetbrains.python.refactoring.classes.ui.PyMemberSelectionTable;
@@ -21,7 +21,7 @@ import com.intellij.refactoring.util.RefactoringUIUtil;
import com.intellij.util.containers.MultiMap;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyFunction;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -17,49 +17,31 @@ package com.jetbrains.python.refactoring.classes.pullUp;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiNamedElement;
import com.intellij.refactoring.RefactoringBundle;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.psi.PyFunction;
import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.MembersManager;
import java.util.*;
import java.util.Collection;
/**
* @author Dennis.Ushakov
*/
public class PyPullUpHelper {
private static final Logger LOG = Logger.getInstance(PyPullUpHelper.class.getName());
private PyPullUpHelper() {}
public final class PyPullUpHelper {
private PyPullUpHelper() {
}
public static PyElement pullUp(final PyClass clazz, final Collection<PyMemberInfo> selectedMemberInfos, final PyClass superClass) {
final Set<String> superClasses = new HashSet<String>();
final Set<PsiNamedElement> extractedClasses = new HashSet<PsiNamedElement>();
final List<PyFunction> methods = new ArrayList<PyFunction>();
for (PyMemberInfo member : selectedMemberInfos) {
final PyElement element = member.getMember();
if (element instanceof PyFunction) methods.add((PyFunction)element);
else if (element instanceof PyClass) {
superClasses.add(element.getName());
extractedClasses.add((PyClass)element);
}
else LOG.error("unmatched member class " + element.getClass());
}
CommandProcessor.getInstance().executeCommand(clazz.getProject(), new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// move methods
PyClassRefactoringUtil.moveMethods(methods, superClass);
// move superclasses declarations
PyClassRefactoringUtil.moveSuperclasses(clazz, superClasses, superClass);
PyClassRefactoringUtil.insertImport(superClass, extractedClasses);
PyClassRefactoringUtil.insertPassIfNeeded(clazz);
MembersManager.moveAllMembers(clazz, superClass, selectedMemberInfos);
}
});
}
@@ -25,7 +25,7 @@ import com.intellij.util.containers.MultiMap;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.psi.PyUtil;
import com.jetbrains.python.refactoring.classes.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo;
import com.jetbrains.python.refactoring.classes.PyMemberInfoStorage;
import org.jetbrains.annotations.NotNull;

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