mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -15,88 +15,28 @@
|
||||
*/
|
||||
package com.intellij.compiler.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactsWorkspaceSettings;
|
||||
import com.intellij.packaging.impl.ui.ChooseArtifactsDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class BuildArtifactAction extends AnAction {
|
||||
public class BuildArtifactAction extends BuildArtifactActionBase {
|
||||
public BuildArtifactAction() {
|
||||
super("Build Artifact");
|
||||
super("Build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(false);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final List<Artifact> artifacts = getArtifactWithOutputPaths(project);
|
||||
if (artifacts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
presentation.setEnabled(true);
|
||||
if (artifacts.size() == 1) {
|
||||
presentation.setText("Build '" + StringUtil.first(artifacts.get(0).getName(), 40, true) + "' artifact");
|
||||
}
|
||||
else {
|
||||
presentation.setText("Build Artifacts...");
|
||||
}
|
||||
protected String getDescription() {
|
||||
return "Selected artifacts will be built with all dependencies";
|
||||
}
|
||||
|
||||
private static List<Artifact> getArtifactWithOutputPaths(Project project) {
|
||||
final List<Artifact> result = new ArrayList<Artifact>();
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getSortedArtifacts()) {
|
||||
if (!StringUtil.isEmpty(artifact.getOutputPath())) {
|
||||
result.add(artifact);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
if (project == null) return;
|
||||
|
||||
final List<Artifact> artifacts = getArtifactWithOutputPaths(project);
|
||||
if (artifacts.isEmpty()) return;
|
||||
|
||||
if (artifacts.size() == 1) {
|
||||
buildArtifacts(project, artifacts);
|
||||
return;
|
||||
}
|
||||
|
||||
final ChooseArtifactsDialog dialog = new ChooseArtifactsDialog(project, artifacts, "Choose Artifacts to Build", "Selected artifacts will be built with all dependencies");
|
||||
final List<Artifact> initialSelection = ArtifactsWorkspaceSettings.getInstance(project).getArtifactsToBuild();
|
||||
if (!initialSelection.isEmpty()) {
|
||||
dialog.selectElements(initialSelection);
|
||||
}
|
||||
dialog.show();
|
||||
|
||||
if (dialog.isOK()) {
|
||||
final List<Artifact> selected = dialog.getChosenElements();
|
||||
ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(selected);
|
||||
buildArtifacts(project, selected);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildArtifacts(Project project, final List<Artifact> artifacts) {
|
||||
@Override
|
||||
protected void performAction(Project project, final List<Artifact> artifacts) {
|
||||
CompilerManager.getInstance(project).make(ArtifactCompileScope.createArtifactsScope(project, artifacts), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.compiler.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactsWorkspaceSettings;
|
||||
import com.intellij.packaging.impl.ui.ChooseArtifactsDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class BuildArtifactActionBase extends AnAction {
|
||||
private final String myActionName;
|
||||
|
||||
public BuildArtifactActionBase(String actionName) {
|
||||
super(actionName + " Artifact");
|
||||
myActionName = actionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(false);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final List<Artifact> artifacts = getArtifactWithOutputPaths(project);
|
||||
if (artifacts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
presentation.setEnabled(true);
|
||||
if (artifacts.size() == 1) {
|
||||
String first = StringUtil.first(artifacts.get(0).getName(), 40, true);
|
||||
presentation.setText(myActionName + " '" + first + "' artifact");
|
||||
}
|
||||
else {
|
||||
presentation.setText(myActionName + " Artifacts...");
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
if (project == null) return;
|
||||
|
||||
final List<Artifact> artifacts = getArtifactWithOutputPaths(project);
|
||||
if (artifacts.isEmpty()) return;
|
||||
|
||||
if (artifacts.size() == 1) {
|
||||
performAction(project, artifacts);
|
||||
return;
|
||||
}
|
||||
|
||||
final ChooseArtifactsDialog dialog = new ChooseArtifactsDialog(project, artifacts, "Choose Artifacts to " + myActionName,
|
||||
getDescription());
|
||||
final List<Artifact> initialSelection = ArtifactsWorkspaceSettings.getInstance(project).getArtifactsToBuild();
|
||||
if (!initialSelection.isEmpty()) {
|
||||
dialog.selectElements(initialSelection);
|
||||
}
|
||||
dialog.show();
|
||||
|
||||
if (dialog.isOK()) {
|
||||
final List<Artifact> selected = dialog.getChosenElements();
|
||||
ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(selected);
|
||||
performAction(project, selected);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getDescription();
|
||||
|
||||
protected abstract void performAction(Project project, List<Artifact> artifacts);
|
||||
|
||||
private static List<Artifact> getArtifactWithOutputPaths(Project project) {
|
||||
final List<Artifact> result = new ArrayList<Artifact>();
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getSortedArtifacts()) {
|
||||
if (!StringUtil.isEmpty(artifact.getOutputPath())) {
|
||||
result.add(artifact);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.compiler.actions;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class CleanArtifactAction extends BuildArtifactActionBase {
|
||||
public CleanArtifactAction() {
|
||||
super("Clean");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDescription() {
|
||||
return "Output of the selected artifacts will be cleared.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performAction(Project project, final List<Artifact> artifacts) {
|
||||
final List<File> files = new ArrayList<File>();
|
||||
for (Artifact artifact : artifacts) {
|
||||
String outputPath = artifact.getOutputFilePath();
|
||||
if (outputPath != null) {
|
||||
files.add(new File(FileUtil.toSystemDependentName(outputPath)));
|
||||
}
|
||||
}
|
||||
new Task.Backgroundable(project, "Cleaning artifacts...", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
for (File file : files) {
|
||||
indicator.checkCanceled();
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
LocalFileSystem.getInstance().refreshIoFiles(files, true, true, null);
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.packaging.impl.artifacts;
|
||||
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
@@ -149,6 +150,12 @@ public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifa
|
||||
|
||||
@Override
|
||||
public VirtualFile getOutputFile() {
|
||||
String filePath = getOutputFilePath();
|
||||
return !StringUtil.isEmpty(filePath) ? LocalFileSystem.getInstance().findFileByPath(filePath) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputFilePath() {
|
||||
String filePath;
|
||||
if (myRootElement instanceof ArchivePackagingElement) {
|
||||
filePath = myOutputPath + "/" + ((ArchivePackagingElement)myRootElement).getArchiveFileName();
|
||||
@@ -156,7 +163,7 @@ public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifa
|
||||
else {
|
||||
filePath = myOutputPath;
|
||||
}
|
||||
return LocalFileSystem.getInstance().findFileByPath(filePath);
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void copyFrom(ArtifactImpl modified) {
|
||||
|
||||
+12
-1
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.elements.ManifestFileUtil;
|
||||
import com.intellij.ui.ComboboxSpeedSearch;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -77,6 +78,11 @@ public class JarArtifactFromModulesDialog extends DialogWrapper {
|
||||
updateManifestDirField();
|
||||
myManifestDirField.addBrowseFolderListener(null, null, project, ManifestFileUtil.createDescriptorForManifestDirectory());
|
||||
|
||||
setupModulesCombobox(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void setupModulesCombobox(PackagingElementResolvingContext context) {
|
||||
final Module[] modules = context.getModulesProvider().getModules().clone();
|
||||
Arrays.sort(modules, ModulesAlphaComparator.INSTANCE);
|
||||
if (modules.length > 1) {
|
||||
@@ -86,7 +92,12 @@ public class JarArtifactFromModulesDialog extends DialogWrapper {
|
||||
myModuleComboBox.addItem(module);
|
||||
}
|
||||
myModuleComboBox.setRenderer(new ModuleListRenderer(myModuleComboBox));
|
||||
init();
|
||||
new ComboboxSpeedSearch(myModuleComboBox) {
|
||||
@Override
|
||||
protected String getElementText(Object element) {
|
||||
return element instanceof Module ? ((Module)element).getName() : "";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void updateManifestDirField() {
|
||||
|
||||
@@ -46,4 +46,7 @@ public interface Artifact extends UserDataHolder {
|
||||
|
||||
@Nullable
|
||||
VirtualFile getOutputFile();
|
||||
|
||||
@Nullable
|
||||
String getOutputFilePath();
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class InplaceIntroduceFieldPopup {
|
||||
private String myFieldName;
|
||||
|
||||
private boolean myInitListeners = false;
|
||||
private static BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace;
|
||||
static BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace;
|
||||
|
||||
public InplaceIntroduceFieldPopup(PsiLocalVariable localVariable,
|
||||
PsiClass parentClass,
|
||||
|
||||
+59
-41
@@ -22,6 +22,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
@@ -33,7 +34,7 @@ import java.awt.event.*;
|
||||
* Date: 4/8/11
|
||||
*/
|
||||
public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
private JComboBox myInitializerCombo;
|
||||
private @Nullable JComboBox myInitializerCombo;
|
||||
private JComboBox myVisibilityCombo;
|
||||
private DefaultComboBoxModel myInitialisersPlaceModel;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
|
||||
protected void initializeControls(PsiExpression initializerExpression, BaseExpressionToFieldHandler.InitializationPlace ourLastInitializerPlace) {
|
||||
super.initializeControls(initializerExpression, ourLastInitializerPlace);
|
||||
initializeInitializerPlace(initializerExpression, ourLastInitializerPlace);
|
||||
|
||||
String ourLastVisibility = JavaRefactoringSettings.getInstance().INTRODUCE_FIELD_VISIBILITY;
|
||||
setVisibility(ourLastVisibility);
|
||||
}
|
||||
@@ -106,7 +107,10 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
}
|
||||
|
||||
public BaseExpressionToFieldHandler.InitializationPlace getInitializerPlace() {
|
||||
return (BaseExpressionToFieldHandler.InitializationPlace)myInitializerCombo.getSelectedItem();
|
||||
if (myInitializerCombo != null) {
|
||||
return (BaseExpressionToFieldHandler.InitializationPlace)myInitializerCombo.getSelectedItem();
|
||||
}
|
||||
return (BaseExpressionToFieldHandler.InitializationPlace)myInitialisersPlaceModel.getElementAt(0);
|
||||
}
|
||||
|
||||
public String getFieldVisibility() {
|
||||
@@ -122,9 +126,7 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(0, 5, 0, 0), 0, 0);
|
||||
gridBagConstraints.insets.top = 5;
|
||||
final JLabel initLabel = new JLabel(RefactoringBundle.message("initialize.in.border.title") + ":");
|
||||
initLabel.setDisplayedMnemonic('i');
|
||||
groupPanel.add(initLabel, gridBagConstraints);
|
||||
|
||||
|
||||
myInitialisersPlaceModel = new DefaultComboBoxModel();
|
||||
myInitialisersPlaceModel.addElement(BaseExpressionToFieldHandler.InitializationPlace.IN_CURRENT_METHOD);
|
||||
@@ -133,40 +135,44 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
if (TestUtil.isTestClass(myParentClass)) {
|
||||
myInitialisersPlaceModel.addElement(BaseExpressionToFieldHandler.InitializationPlace.IN_SETUP_METHOD);
|
||||
}
|
||||
myInitializerCombo = new JComboBox(myInitialisersPlaceModel);
|
||||
InplaceIntroduceConstantPopup.appendActions(myInitializerCombo, myParentClass.getProject());
|
||||
initLabel.setLabelFor(myInitializerCombo);
|
||||
myInitializerCombo.setRenderer(new ListCellRendererWrapper<BaseExpressionToFieldHandler.InitializationPlace>(myInitializerCombo) {
|
||||
@Override
|
||||
public void customize(JList list,
|
||||
BaseExpressionToFieldHandler.InitializationPlace value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_CURRENT_METHOD) {
|
||||
setText("current method");
|
||||
} else if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR) {
|
||||
setText("constructor");
|
||||
} else if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION) {
|
||||
setText("field declaration");
|
||||
} else {
|
||||
setText("setUp");
|
||||
initializeInitializerPlace(myInitializerExpression, InplaceIntroduceFieldPopup.ourLastInitializerPlace);
|
||||
if (myInitialisersPlaceModel.getSize() > 1) {
|
||||
final JLabel initLabel = new JLabel(RefactoringBundle.message("initialize.in.border.title") + ":");
|
||||
initLabel.setDisplayedMnemonic('i');
|
||||
groupPanel.add(initLabel, gridBagConstraints);
|
||||
JComboBox initializersCombo = new JComboBox(myInitialisersPlaceModel);
|
||||
InplaceIntroduceConstantPopup.appendActions(initializersCombo, myParentClass.getProject());
|
||||
initLabel.setLabelFor(initializersCombo);
|
||||
initializersCombo.setRenderer(new ListCellRendererWrapper<BaseExpressionToFieldHandler.InitializationPlace>(initializersCombo) {
|
||||
@Override
|
||||
public void customize(JList list,
|
||||
BaseExpressionToFieldHandler.InitializationPlace value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
setText(getPresentableText(value));
|
||||
}
|
||||
}
|
||||
});
|
||||
myInitializerCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
itemListener.itemStateChanged(null);
|
||||
finalUpdater.itemStateChanged(null);
|
||||
}
|
||||
});
|
||||
gridBagConstraints.gridx = 1;
|
||||
gridBagConstraints.insets.top = 0;
|
||||
gridBagConstraints.insets.left = 0;
|
||||
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
groupPanel.add(myInitializerCombo, gridBagConstraints);
|
||||
|
||||
});
|
||||
initializersCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
itemListener.itemStateChanged(null);
|
||||
finalUpdater.itemStateChanged(null);
|
||||
}
|
||||
});
|
||||
gridBagConstraints.gridx = 1;
|
||||
gridBagConstraints.insets.top = 0;
|
||||
gridBagConstraints.insets.left = 0;
|
||||
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
groupPanel.add(initializersCombo, gridBagConstraints);
|
||||
myInitializerCombo = initializersCombo;
|
||||
} else {
|
||||
gridBagConstraints.gridwidth = 2;
|
||||
groupPanel.add(new JLabel("Initialize field in " +
|
||||
getPresentableText((BaseExpressionToFieldHandler.InitializationPlace)myInitialisersPlaceModel.getElementAt(0))),
|
||||
gridBagConstraints);
|
||||
gridBagConstraints.gridwidth = 1;
|
||||
}
|
||||
|
||||
|
||||
gridBagConstraints.gridx = 0;
|
||||
@@ -180,6 +186,18 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private static String getPresentableText(BaseExpressionToFieldHandler.InitializationPlace value) {
|
||||
if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_CURRENT_METHOD) {
|
||||
return "current method";
|
||||
} else if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR) {
|
||||
return "constructor";
|
||||
} else if (value == BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION) {
|
||||
return "field declaration";
|
||||
} else {
|
||||
return "setUp";
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean setEnabledInitializationPlaces(PsiElement initializerPart, PsiElement initializer) {
|
||||
if (initializerPart instanceof PsiReferenceExpression) {
|
||||
PsiReferenceExpression refExpr = (PsiReferenceExpression) initializerPart;
|
||||
@@ -191,7 +209,6 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
myInitialisersPlaceModel.removeElement(BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION);
|
||||
myInitialisersPlaceModel.removeElement(BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR);
|
||||
myInitialisersPlaceModel.removeElement(BaseExpressionToFieldHandler.InitializationPlace.IN_SETUP_METHOD);
|
||||
enableFinal(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -213,6 +230,7 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
}
|
||||
|
||||
public void setInitializeInFieldDeclaration() {
|
||||
LOG.assertTrue(myInitializerCombo != null);
|
||||
myInitializerCombo.setSelectedItem(BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION);
|
||||
}
|
||||
|
||||
@@ -222,7 +240,7 @@ public class IntroduceFieldPopupPanel extends IntroduceFieldCentralPanel {
|
||||
|
||||
@Override
|
||||
protected boolean allowFinal() {
|
||||
final Object selectedItem = myInitializerCombo.getSelectedItem();
|
||||
final Object selectedItem = getInitializerPlace();
|
||||
boolean allowFinal = selectedItem == BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION ||
|
||||
(selectedItem == BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR && !myWillBeDeclaredStatic);
|
||||
if (selectedItem == BaseExpressionToFieldHandler.InitializationPlace.IN_CURRENT_METHOD && myIsCurrentMethodConstructor) {
|
||||
|
||||
+4
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
@@ -45,6 +46,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntProcedure;
|
||||
import sun.util.LocaleServiceProviderPool;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -76,6 +78,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
|
||||
private JComboBox myReplaceFieldsCb;
|
||||
private boolean myInitialized = false;
|
||||
private static final Logger LOG = Logger.getInstance("#" + InplaceIntroduceParameterPopup.class.getName());
|
||||
|
||||
|
||||
InplaceIntroduceParameterPopup(final Project project,
|
||||
@@ -204,6 +207,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
nameSuggestions.add(parameter.getName());
|
||||
nameSuggestions.addAll(Arrays.asList(names));
|
||||
final VariableInplaceRenamer renamer = new ParameterInplaceIntroducer(parameter);
|
||||
LOG.assertTrue(parameter.isPhysical());
|
||||
renamer.performInplaceRename(false, nameSuggestions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.navigation;
|
||||
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.PsiNavigateUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,9 +54,9 @@ public class GotoRelatedItem {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
public static List<GotoRelatedItem> createItems(@NotNull Collection<? extends NavigatablePsiElement> elements) {
|
||||
public static List<GotoRelatedItem> createItems(@NotNull Collection<? extends PsiElement> elements) {
|
||||
List<GotoRelatedItem> items = new ArrayList<GotoRelatedItem>(elements.size());
|
||||
for (NavigatablePsiElement element : elements) {
|
||||
for (PsiElement element : elements) {
|
||||
items.add(new GotoRelatedItem(element));
|
||||
}
|
||||
return items;
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -26,6 +29,15 @@ public class SwitchToFind extends EditorHeaderAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
if (KeymapUtil.isEmacsKeymap(KeymapManager.getInstance().getActiveKeymap())) {
|
||||
// Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that
|
||||
// activates 'incremental search'. Hence, we do the similar hack here for them.
|
||||
AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT);
|
||||
action.update(e);
|
||||
action.actionPerformed(e);
|
||||
return;
|
||||
}
|
||||
|
||||
final FindModel findModel = getEditorSearchComponent().getFindModel();
|
||||
FindUtil.configureFindModel(false, getEditorSearchComponent().getEditor(), findModel);
|
||||
}
|
||||
|
||||
@@ -65,14 +65,41 @@ import java.util.*;
|
||||
public class FileTemplateUtil{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.fileTemplates.FileTemplateUtil");
|
||||
@NonNls private static final String FILE_RESOURCE_LOADER_INSTANCE = "file.resource.loader.instance";
|
||||
private static boolean ourVelocityInitialized = false;
|
||||
private static final CreateFromTemplateHandler ourDefaultCreateFromTemplateHandler = new DefaultCreateFromTemplateHandler();
|
||||
|
||||
private FileTemplateUtil() {
|
||||
}
|
||||
|
||||
static {
|
||||
try{
|
||||
File modifiedPatternsPath = new File(PathManager.getConfigPath());
|
||||
modifiedPatternsPath = new File(modifiedPatternsPath, "fileTemplates");
|
||||
modifiedPatternsPath = new File(modifiedPatternsPath, "includes");
|
||||
|
||||
LogSystem emptyLogSystem = new LogSystem() {
|
||||
public void init(RuntimeServices runtimeServices) throws Exception {
|
||||
}
|
||||
|
||||
public void logVelocityMessage(int i, String s) {
|
||||
//todo[myakovlev] log somethere?
|
||||
}
|
||||
};
|
||||
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, emptyLogSystem);
|
||||
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "file,class");
|
||||
//todo[myakovlev] implement my own Loader, with ability to load templates from classpath
|
||||
Velocity.setProperty(FILE_RESOURCE_LOADER_INSTANCE, new FileResourceLoader());
|
||||
Velocity.setProperty("class.resource.loader.class", MyClasspathResourceLoader.class.getName());
|
||||
Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, modifiedPatternsPath.getAbsolutePath());
|
||||
Velocity.setProperty(RuntimeConstants.INPUT_ENCODING, FileTemplate.ourEncoding);
|
||||
Velocity.setProperty(RuntimeConstants.PARSER_POOL_SIZE, 3);
|
||||
Velocity.init();
|
||||
}
|
||||
catch (Exception e){
|
||||
LOG.error("Unable to init Velocity", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] calculateAttributes(String templateContent, Properties properties, boolean includeDummies) throws ParseException {
|
||||
initVelocity();
|
||||
final Set<String> unsetAttributes = new HashSet<String>();
|
||||
final Set<String> definedAttributes = new HashSet<String>();
|
||||
//noinspection HardCodedStringLiteral
|
||||
@@ -161,7 +188,6 @@ public class FileTemplateUtil{
|
||||
}
|
||||
|
||||
public static String mergeTemplate(Map attributes, String content) throws IOException{
|
||||
initVelocity();
|
||||
VelocityContext context = new VelocityContext();
|
||||
for (final Object o : attributes.keySet()) {
|
||||
String name = (String)o;
|
||||
@@ -171,7 +197,6 @@ public class FileTemplateUtil{
|
||||
}
|
||||
|
||||
public static String mergeTemplate(Properties attributes, String content) throws IOException{
|
||||
initVelocity();
|
||||
VelocityContext context = new VelocityContext();
|
||||
Enumeration<?> names = attributes.propertyNames();
|
||||
while (names.hasMoreElements()){
|
||||
@@ -182,7 +207,6 @@ public class FileTemplateUtil{
|
||||
}
|
||||
|
||||
private static String mergeTemplate(String templateContent, final VelocityContext context) throws IOException {
|
||||
initVelocity();
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
try {
|
||||
Velocity.evaluate(context, stringWriter, "", templateContent);
|
||||
@@ -199,43 +223,8 @@ public class FileTemplateUtil{
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static synchronized void initVelocity(){
|
||||
try{
|
||||
if (ourVelocityInitialized) {
|
||||
return;
|
||||
}
|
||||
File modifiedPatternsPath = new File(PathManager.getConfigPath());
|
||||
modifiedPatternsPath = new File(modifiedPatternsPath, "fileTemplates");
|
||||
modifiedPatternsPath = new File(modifiedPatternsPath, "includes");
|
||||
|
||||
LogSystem emptyLogSystem = new LogSystem() {
|
||||
public void init(RuntimeServices runtimeServices) throws Exception {
|
||||
}
|
||||
|
||||
public void logVelocityMessage(int i, String s) {
|
||||
//todo[myakovlev] log somethere?
|
||||
}
|
||||
};
|
||||
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, emptyLogSystem);
|
||||
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "file,class");
|
||||
//todo[myakovlev] implement my own Loader, with ability to load templates from classpath
|
||||
Velocity.setProperty(FILE_RESOURCE_LOADER_INSTANCE, new FileResourceLoader());
|
||||
Velocity.setProperty("class.resource.loader.class", MyClasspathResourceLoader.class.getName());
|
||||
Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, modifiedPatternsPath.getAbsolutePath());
|
||||
Velocity.setProperty(RuntimeConstants.INPUT_ENCODING, FileTemplate.ourEncoding);
|
||||
Velocity.setProperty(RuntimeConstants.PARSER_POOL_SIZE, 3);
|
||||
Velocity.init();
|
||||
ourVelocityInitialized = true;
|
||||
}
|
||||
catch (Exception e){
|
||||
LOG.error("Unable to init Velocity", e);
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void addResourcesDir(File dir) {
|
||||
initVelocity();
|
||||
final FileResourceLoader loader = (FileResourceLoader)Velocity.getProperty(FILE_RESOURCE_LOADER_INSTANCE);
|
||||
try {
|
||||
Field pathsField = FileResourceLoader.class.getDeclaredField("paths");
|
||||
@@ -341,10 +330,10 @@ public class FileTemplateUtil{
|
||||
return methodText.replaceAll("\n", "\n" + StringUtil.repeatSymbol(' ',indent));
|
||||
}
|
||||
|
||||
@NonNls private static final String INCLUDES_PATH = "fileTemplates/includes/";
|
||||
|
||||
public static class MyClasspathResourceLoader extends ClasspathResourceLoader{
|
||||
@NonNls private static final String FT_EXTENSION = ".ft";
|
||||
private static final String INCLUDES_PATH = "fileTemplates/includes/";
|
||||
private static final String FT_EXTENSION = ".ft";
|
||||
|
||||
public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException{
|
||||
return super.getResourceStream(INCLUDES_PATH + name + FT_EXTENSION);
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -61,6 +62,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.diff.Diff;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -441,16 +443,30 @@ public abstract class ChooseByNameBase {
|
||||
}
|
||||
});
|
||||
|
||||
final Set<KeyStroke> upShortcuts = getShortcuts(IdeActions.ACTION_EDITOR_MOVE_CARET_UP);
|
||||
final Set<KeyStroke> downShortcuts = getShortcuts(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN);
|
||||
myTextField.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER && (e.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER && (e.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
|
||||
myClosedByShiftEnter = true;
|
||||
close(true);
|
||||
}
|
||||
if (!myListScrollPane.isVisible()) {
|
||||
return;
|
||||
}
|
||||
final int keyCode = e.getKeyCode();
|
||||
final int keyCode;
|
||||
|
||||
// Add support for user-defined 'caret up/down' shortcuts.
|
||||
KeyStroke stroke = KeyStroke.getKeyStrokeForEvent(e);
|
||||
if (upShortcuts.contains(stroke)) {
|
||||
keyCode = KeyEvent.VK_UP;
|
||||
}
|
||||
else if (downShortcuts.contains(stroke)) {
|
||||
keyCode = KeyEvent.VK_DOWN;
|
||||
}
|
||||
else {
|
||||
keyCode = e.getKeyCode();
|
||||
}
|
||||
switch (keyCode) {
|
||||
case KeyEvent.VK_DOWN:
|
||||
ListScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
@@ -529,6 +545,22 @@ public abstract class ChooseByNameBase {
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<KeyStroke> getShortcuts(@NotNull String actionId) {
|
||||
Set<KeyStroke> result = new HashSet<KeyStroke>();
|
||||
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
Shortcut[] shortcuts = keymap.getShortcuts(actionId);
|
||||
if (shortcuts == null) {
|
||||
return result;
|
||||
}
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
|
||||
result.add(keyboardShortcut.getFirstKeyStroke());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void hideHint() {
|
||||
if (!myTextFieldPanel.focusRequested()) {
|
||||
doClose(false);
|
||||
@@ -678,7 +710,7 @@ public abstract class ChooseByNameBase {
|
||||
|
||||
protected void rebuildList(final int pos,
|
||||
final int delay,
|
||||
final Runnable postRunnable,
|
||||
final @Nullable Runnable postRunnable,
|
||||
final ModalityState modalityState,
|
||||
final @Nullable ComponentEvent e) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
+5
-4
@@ -41,9 +41,8 @@ public class EnforcedPlainTextFileTypeFactory extends FileTypeFactory {
|
||||
|
||||
|
||||
private final FileTypeIdentifiableByVirtualFile myFileType;
|
||||
private static final EnforcedPlainTextFileTypeManager ourManager = EnforcedPlainTextFileTypeManager.getInstance();
|
||||
|
||||
|
||||
|
||||
|
||||
public EnforcedPlainTextFileTypeFactory() {
|
||||
|
||||
|
||||
@@ -102,7 +101,9 @@ public class EnforcedPlainTextFileTypeFactory extends FileTypeFactory {
|
||||
}
|
||||
|
||||
private static boolean isMarkedAsPlainText(VirtualFile file) {
|
||||
return ourManager != null && ourManager.isMarkedAsPlainText(file);
|
||||
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
|
||||
if (typeManager == null) return false;
|
||||
return typeManager.isMarkedAsPlainText(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-1
@@ -60,8 +60,12 @@ public class EnforcedPlainTextFileTypeManager extends PersistentFileSetManager {
|
||||
});
|
||||
}
|
||||
|
||||
private final static EnforcedPlainTextFileTypeManager ourInstance = ServiceManager.getService(EnforcedPlainTextFileTypeManager.class);
|
||||
private static EnforcedPlainTextFileTypeManager ourInstance;
|
||||
|
||||
public static EnforcedPlainTextFileTypeManager getInstance() {
|
||||
if (ourInstance == null) {
|
||||
ourInstance = ServiceManager.getService(EnforcedPlainTextFileTypeManager.class);
|
||||
}
|
||||
return ourInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ComponentConfig;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -383,11 +382,13 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof IdeaPluginDescriptorImpl)) return false;
|
||||
|
||||
return Comparing.equal(myId, ((IdeaPluginDescriptorImpl)o).myId);
|
||||
final IdeaPluginDescriptorImpl pluginDescriptor = (IdeaPluginDescriptorImpl)o;
|
||||
|
||||
return myName == null ? pluginDescriptor.myName == null : myName.equals(pluginDescriptor.myName);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myId != null ? myId.hashCode() : 0;
|
||||
return myName != null ? myName.hashCode() : 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.registry.RegistryValue;
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -39,6 +40,7 @@ import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class KeymapUtil {
|
||||
|
||||
private static final Icon ourKeyboardShortcutIcon = IconLoader.getIcon("/general/keyboardShortcut.png");
|
||||
private static final Icon ourMouseShortcutIcon = IconLoader.getIcon("/general/mouseShortcut.png");
|
||||
@NonNls private static final String APPLE_LAF_AQUA_LOOK_AND_FEEL_CLASS_NAME = "apple.laf.AquaLookAndFeel";
|
||||
@@ -60,6 +62,9 @@ public class KeymapUtil {
|
||||
private static final Set<Integer> ourOtherTooltipKeys = new HashSet<Integer>();
|
||||
private static RegistryValue ourTooltipKeysProperty;
|
||||
|
||||
private KeymapUtil() {
|
||||
}
|
||||
|
||||
public static String getShortcutText(Shortcut shortcut) {
|
||||
String s = "";
|
||||
|
||||
@@ -99,6 +104,9 @@ public class KeymapUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param button target mouse button
|
||||
* @param modifiers modifiers used within the target click
|
||||
* @param clickCount target clicks count
|
||||
* @return string representation of passed mouse shortcut.
|
||||
*/
|
||||
public static String getMouseShortcutText(int button, int modifiers, int clickCount) {
|
||||
@@ -176,12 +184,12 @@ public class KeymapUtil {
|
||||
if (SystemInfo.isMac) {
|
||||
try {
|
||||
Class appleLaf = Class.forName(APPLE_LAF_AQUA_LOOK_AND_FEEL_CLASS_NAME);
|
||||
Method getModifiers = appleLaf.getMethod(GET_KEY_MODIFIERS_TEXT_METHOD, new Class[]{int.class, boolean.class});
|
||||
return (String)getModifiers.invoke(appleLaf, new Object[]{new Integer(modifiers), Boolean.FALSE});
|
||||
Method getModifiers = appleLaf.getMethod(GET_KEY_MODIFIERS_TEXT_METHOD, int.class, boolean.class);
|
||||
return (String)getModifiers.invoke(appleLaf, modifiers, Boolean.FALSE);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (SystemInfo.isMacOSLeopard) {
|
||||
return KeymapUtil.getKeyModifiersTextForMacOSLeopard(modifiers);
|
||||
return getKeyModifiersTextForMacOSLeopard(modifiers);
|
||||
}
|
||||
|
||||
// OK do nothing here.
|
||||
@@ -198,8 +206,7 @@ public class KeymapUtil {
|
||||
|
||||
public static String getFirstKeyboardShortcutText(AnAction action) {
|
||||
Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
|
||||
for (int i = 0; i < shortcuts.length; i++) {
|
||||
Shortcut shortcut = shortcuts[i];
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (shortcut instanceof KeyboardShortcut) {
|
||||
return getShortcutText(shortcut);
|
||||
}
|
||||
@@ -211,20 +218,22 @@ public class KeymapUtil {
|
||||
if (shortcuts.length == 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int i = 0; i < shortcuts.length; i++) {
|
||||
Shortcut shortcut = shortcuts[i];
|
||||
if (i > 0) {
|
||||
buffer.append(' ');
|
||||
}
|
||||
buffer.append(KeymapUtil.getShortcutText(shortcut));
|
||||
buffer.append(getShortcutText(shortcut));
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method. It parses passed string and creates <code>MouseShortcut</code>.
|
||||
*
|
||||
*
|
||||
* @param keystrokeString target keystroke
|
||||
* @return shortcut for the given keystroke
|
||||
* @throws InvalidDataException if <code>keystrokeString</code> doesn't represent valid <code>MouseShortcut</code>.
|
||||
*/
|
||||
public static MouseShortcut parseMouseShortcut(String keystrokeString) throws InvalidDataException {
|
||||
@@ -234,19 +243,19 @@ public class KeymapUtil {
|
||||
for (StringTokenizer tokenizer = new StringTokenizer(keystrokeString); tokenizer.hasMoreTokens();) {
|
||||
String token = tokenizer.nextToken();
|
||||
if (SHIFT.equals(token)) {
|
||||
modifiers |= MouseEvent.SHIFT_DOWN_MASK;
|
||||
modifiers |= InputEvent.SHIFT_DOWN_MASK;
|
||||
}
|
||||
else if (CONTROL.equals(token) || CTRL.equals(token)) {
|
||||
modifiers |= MouseEvent.CTRL_DOWN_MASK;
|
||||
modifiers |= InputEvent.CTRL_DOWN_MASK;
|
||||
}
|
||||
else if (META.equals(token)) {
|
||||
modifiers |= MouseEvent.META_DOWN_MASK;
|
||||
modifiers |= InputEvent.META_DOWN_MASK;
|
||||
}
|
||||
else if (ALT.equals(token)) {
|
||||
modifiers |= MouseEvent.ALT_DOWN_MASK;
|
||||
modifiers |= InputEvent.ALT_DOWN_MASK;
|
||||
}
|
||||
else if (ALT_GRAPH.equals(token)) {
|
||||
modifiers |= MouseEvent.ALT_GRAPH_DOWN_MASK;
|
||||
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
|
||||
}
|
||||
else if (BUTTON1.equals(token)) {
|
||||
button = MouseEvent.BUTTON1;
|
||||
@@ -268,7 +277,7 @@ public class KeymapUtil {
|
||||
}
|
||||
|
||||
public static String getKeyModifiersTextForMacOSLeopard(int modifiers) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if ((modifiers & InputEvent.META_MASK) != 0) {
|
||||
buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
|
||||
}
|
||||
@@ -324,10 +333,10 @@ public class KeymapUtil {
|
||||
ourTooltipKeys.clear();
|
||||
ourOtherTooltipKeys.clear();
|
||||
|
||||
processKey(text.contains("meta"), KeyEvent.META_MASK);
|
||||
processKey(text.contains("control") | text.contains("ctrl"), KeyEvent.CTRL_MASK);
|
||||
processKey(text.contains("shift"), KeyEvent.SHIFT_MASK);
|
||||
processKey(text.contains("alt"), KeyEvent.ALT_MASK);
|
||||
processKey(text.contains("meta"), InputEvent.META_MASK);
|
||||
processKey(text.contains("control") | text.contains("ctrl"), InputEvent.CTRL_MASK);
|
||||
processKey(text.contains("shift"), InputEvent.SHIFT_MASK);
|
||||
processKey(text.contains("alt"), InputEvent.ALT_MASK);
|
||||
|
||||
}
|
||||
|
||||
@@ -338,4 +347,13 @@ public class KeymapUtil {
|
||||
ourOtherTooltipKeys.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEmacsKeymap(@Nullable Keymap keymap) {
|
||||
for (; keymap != null; keymap = keymap.getParent()) {
|
||||
if ("Emacs".equalsIgnoreCase(keymap.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,22 @@ public class LoadingDecorator {
|
||||
Disposer.register(parent, myLoadingLayer.myProgress);
|
||||
}
|
||||
|
||||
protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
|
||||
parent.setLayout(new GridBagLayout());
|
||||
|
||||
final Font font = text.getFont();
|
||||
text.setFont(font.deriveFont(font.getStyle(), font.getSize() + 8));
|
||||
text.setForeground(Color.black);
|
||||
|
||||
final int gap = new JLabel().getIconTextGap();
|
||||
final NonOpaquePanel result = new NonOpaquePanel(new FlowLayout(FlowLayout.CENTER, gap * 3, 0));
|
||||
result.add(icon);
|
||||
result.add(text);
|
||||
parent.add(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myPane;
|
||||
}
|
||||
@@ -121,8 +137,7 @@ public class LoadingDecorator {
|
||||
}
|
||||
|
||||
private class LoadingLayer extends JPanel {
|
||||
|
||||
private final JLabel myText;
|
||||
private final JLabel myText = new JLabel("", SwingConstants.CENTER);
|
||||
|
||||
private BufferedImage mySnapshot;
|
||||
private Color mySnapshotBg;
|
||||
@@ -137,22 +152,8 @@ public class LoadingDecorator {
|
||||
private LoadingLayer() {
|
||||
setOpaque(false);
|
||||
setVisible(false);
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
myText = new JLabel("", JLabel.CENTER);
|
||||
final Font font = myText.getFont();
|
||||
myText.setFont(font.deriveFont(font.getStyle(), font.getSize() + 8));
|
||||
myText.setForeground(Color.black);
|
||||
myProgress.setOpaque(false);
|
||||
|
||||
|
||||
final int gap = new JLabel().getIconTextGap();
|
||||
myTextComponent = new NonOpaquePanel(new FlowLayout(FlowLayout.CENTER, gap * 3, 0));
|
||||
myTextComponent.add(myProgress);
|
||||
myTextComponent.add(myText);
|
||||
|
||||
add(myTextComponent);
|
||||
|
||||
myTextComponent = customizeLoadingLayer(this, myText, myProgress);
|
||||
myProgress.suspend();
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public class Messages {
|
||||
}
|
||||
}
|
||||
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, int focusedOptionIndex, Icon icon, DialogWrapper.DoNotAskOption doNotAskOption) {
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
|
||||
if (isApplicationInUnitTestOrHeadless()) {
|
||||
return ourTestImplementation.show(message);
|
||||
}
|
||||
@@ -157,26 +157,26 @@ public class Messages {
|
||||
* @see #showDialog(Project, String, String, String[], int, Icon)
|
||||
* @see #showDialog(Component, String, String, String[], int, Icon)
|
||||
*/
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, Icon icon, DialogWrapper.DoNotAskOption doNotAskOption) {
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
|
||||
return showDialog(message, title, options, defaultOptionIndex, -1, icon, doNotAskOption);
|
||||
}
|
||||
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, Icon icon) {
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) {
|
||||
return showDialog(message, title, options, defaultOptionIndex, -1, icon);
|
||||
}
|
||||
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
|
||||
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon) {
|
||||
return showDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.ui.DialogWrapper#DialogWrapper(Project,boolean)
|
||||
*/
|
||||
public static void showMessageDialog(Project project, String message, String title, Icon icon) {
|
||||
public static void showMessageDialog(Project project, String message, String title, @Nullable Icon icon) {
|
||||
showDialog(project, message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(Component parent, String message, String title, Icon icon) {
|
||||
public static void showMessageDialog(Component parent, String message, String title, @Nullable Icon icon) {
|
||||
showDialog(parent, message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
@@ -186,21 +186,21 @@ public class Messages {
|
||||
* @see #showMessageDialog(Project, String, String, Icon)
|
||||
* @see #showMessageDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static void showMessageDialog(String message, String title, Icon icon) {
|
||||
public static void showMessageDialog(String message, String title, @Nullable Icon icon) {
|
||||
showDialog(message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
*/
|
||||
public static int showYesNoDialog(Project project, String message, String title, Icon icon) {
|
||||
public static int showYesNoDialog(Project project, String message, String title, @Nullable Icon icon) {
|
||||
return showDialog(project, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
*/
|
||||
public static int showYesNoDialog(Component parent, String message, String title, Icon icon) {
|
||||
public static int showYesNoDialog(Component parent, String message, String title, @Nullable Icon icon) {
|
||||
return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class Messages {
|
||||
* @see #showYesNoDialog(Project, String, String, Icon)
|
||||
* @see #showYesNoDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static int showYesNoDialog(String message, String title, Icon icon) {
|
||||
public static int showYesNoDialog(String message, String title, @Nullable Icon icon) {
|
||||
return showDialog(message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ public class Messages {
|
||||
super(project, false);
|
||||
}
|
||||
|
||||
protected void _init(String title, String message, String[] options, int defaultOptionIndex, int focusedOptionIndex, Icon icon, DoNotAskOption doNotAskOption) {
|
||||
protected void _init(String title, String message, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon, @Nullable DoNotAskOption doNotAskOption) {
|
||||
setTitle(title);
|
||||
myMessage = message;
|
||||
myOptions = options;
|
||||
@@ -694,7 +694,7 @@ public class Messages {
|
||||
return actions;
|
||||
}
|
||||
|
||||
private void assignMnemonic(String option, Action action) {
|
||||
private static void assignMnemonic(String option, Action action) {
|
||||
int mnemoPos = option.indexOf("&");
|
||||
if (mnemoPos >= 0 && mnemoPos < option.length() - 2) {
|
||||
String mnemoChar = option.substring(mnemoPos + 1, mnemoPos + 2).trim();
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface CachedValueProvider<T> {
|
||||
private final Object[] myDependencyItems;
|
||||
private boolean myLockValue = false;
|
||||
|
||||
public Result(T value, Object... dependencyItems) {
|
||||
public Result(@Nullable T value, Object... dependencyItems) {
|
||||
myValue = value;
|
||||
myDependencyItems = dependencyItems;
|
||||
}
|
||||
@@ -39,11 +39,11 @@ public interface CachedValueProvider<T> {
|
||||
return myDependencyItems;
|
||||
}
|
||||
|
||||
public static <T> Result<T> createSingleDependency(T value, Object dependency) {
|
||||
public static <T> Result<T> createSingleDependency(@Nullable T value, Object dependency) {
|
||||
return create(value, dependency);
|
||||
}
|
||||
|
||||
public static <T> Result<T> create(T value, Object... dependencies) {
|
||||
public static <T> Result<T> create(@Nullable T value, Object... dependencies) {
|
||||
return new Result<T>(value, dependencies);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -41,9 +42,9 @@ public class EditorNotifications extends AbstractProjectComponent {
|
||||
|
||||
public interface Provider<T extends JComponent> {
|
||||
|
||||
|
||||
Key<T> getKey();
|
||||
|
||||
|
||||
@Nullable
|
||||
T createNotificationPanel(VirtualFile file);
|
||||
|
||||
@@ -110,4 +111,11 @@ public class EditorNotifications extends AbstractProjectComponent {
|
||||
editor.putUserData(key, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateAll() {
|
||||
Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
for (Project project : projects) {
|
||||
getInstance(project).updateAllNotifications();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -127,6 +127,7 @@ public class JBComboBoxTableCellEditorComponent extends JBLabel {
|
||||
@Override
|
||||
public void run() {
|
||||
myValue = myList.getSelectedValue();
|
||||
myTable.setValueAt(myValue, myRow, myColumn); // on Mac getCellEditorValue() called before myValue is set.
|
||||
}
|
||||
}).createPopup()
|
||||
.show(new RelativePoint(myTable, point));
|
||||
|
||||
+3
-2
@@ -206,8 +206,9 @@ public final class IdeMouseEventDispatcher {
|
||||
}
|
||||
|
||||
private static int getScrollAmount(Component c, MouseWheelEvent me, JScrollBar scrollBar) {
|
||||
final int ratio = Registry.is("ide.smart.horizontal.scrolling")
|
||||
? Math.max((int)Math.pow(c.getWidth() / scrollBar.getWidth() , 2), 10) : 10; // do annoying scrolling faster if smart scrolling is on
|
||||
final int scrollBarWidth = scrollBar.getWidth();
|
||||
final int ratio = Registry.is("ide.smart.horizontal.scrolling") && scrollBarWidth > 0
|
||||
? Math.max((int)Math.pow(c.getWidth() / scrollBarWidth, 2), 10) : 10; // do annoying scrolling faster if smart scrolling is on
|
||||
return me.getUnitsToScroll() * scrollBar.getUnitIncrement() * ratio;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ide.ui;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -87,7 +89,7 @@ public abstract class ListCellRendererWrapper<T> implements ListCellRenderer {
|
||||
*/
|
||||
public abstract void customize(final JList list, final T value, final int index, final boolean selected, final boolean hasFocus);
|
||||
|
||||
public final void setIcon(final Icon icon) {
|
||||
public final void setIcon(final @Nullable Icon icon) {
|
||||
myIcon = icon;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public class DTree {
|
||||
private DiffElement<?> myTarget;
|
||||
private DType type;
|
||||
private boolean myVisible = true;
|
||||
private String mySeparator = null;
|
||||
private String myPath = null;
|
||||
|
||||
public DTree(@Nullable DTree parent, @NotNull String name, boolean container) {
|
||||
this.myParent = parent;
|
||||
@@ -209,16 +211,21 @@ public class DTree {
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
final DTree parent = getParent();
|
||||
if (parent != null) {
|
||||
return parent.getPath() + getName() + (isContainer ? getSeparator() : "");
|
||||
} else {
|
||||
return getName() + (isContainer ? getSeparator() : "");
|
||||
if (myPath == null) {
|
||||
final DTree parent = getParent();
|
||||
if (parent != null) {
|
||||
myPath = parent.getPath() + getName() + (isContainer ? getSeparator() : "");
|
||||
} else {
|
||||
myPath = getName() + (isContainer ? getSeparator() : "");
|
||||
}
|
||||
}
|
||||
return myPath;
|
||||
}
|
||||
|
||||
private String getSeparator() {
|
||||
final String s = mySource != null ? mySource.getSeparator() : myTarget != null ? myTarget.getSeparator() : "";
|
||||
return s;
|
||||
if (mySeparator == null) {
|
||||
mySeparator = mySource != null ? mySource.getSeparator() : myTarget != null ? myTarget.getSeparator() : "";
|
||||
}
|
||||
return mySeparator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ public class DirDiffDialog extends DialogWrapper {
|
||||
setTitle("Directory Diff");
|
||||
init();
|
||||
final JBTable table = myDiffPanel.getTable();
|
||||
table.changeSelection(myModel.getElementAt(0).isSeparator() ? 1 : 0, 3, false, false);
|
||||
//final DirDiffElement element = myModel.getElementAt(0);
|
||||
//table.changeSelection(element.isSeparator() ? 1 : 0, 3, false, false);
|
||||
table.setColumnSelectionAllowed(false);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.getTableHeader().setResizingAllowed(false);
|
||||
@@ -61,6 +62,11 @@ public class DirDiffDialog extends DialogWrapper {
|
||||
return myDiffPanel.getTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
super.doCancelAction();
|
||||
|
||||
@@ -17,13 +17,8 @@ package com.intellij.openapi.diff.impl.dir;
|
||||
|
||||
import com.intellij.ide.diff.DiffElement;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diff.DirDiffManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -38,24 +33,8 @@ public class DirDiffManagerImpl extends DirDiffManager {
|
||||
|
||||
@Override
|
||||
public void showDiff(@NotNull final DiffElement dir1, @NotNull final DiffElement dir2, final DirDiffSettings settings) {
|
||||
Task.Backgroundable task = new Task.Backgroundable(myProject, "Directory comparison", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
indicator.setText("Calculating differences");
|
||||
final DirDiffTableModel model = new DirDiffTableModel(myProject, dir1, dir2, indicator, settings);
|
||||
final Runnable run = new Runnable() {
|
||||
public void run() {
|
||||
if (model.getRowCount() == 0) {
|
||||
Messages.showInfoMessage(myProject, "No difference has been found", "Directory Diff Tool");
|
||||
} else {
|
||||
new DirDiffDialog(myProject, model, settings).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
ApplicationManager.getApplication().invokeLater(run);
|
||||
}
|
||||
};
|
||||
ProgressManager.getInstance().run(task);
|
||||
final DirDiffTableModel model = new DirDiffTableModel(myProject, dir1, dir2, settings);
|
||||
new DirDiffDialog(myProject, model, settings).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,137 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.diff.impl.dir.DirDiffPanel">
|
||||
<grid id="27dc6" binding="myComponent" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<grid id="60e4d" binding="myRootPanel" custom-create="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="876" height="554"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<splitpane id="2c9d2" binding="mySplitPanel">
|
||||
<grid id="27dc6" binding="myComponent" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<orientation value="0"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="31406" binding="myDiffPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<splitpane position="right"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<scrollpane id="90582" class="com.intellij.ui.components.JBScrollPane" binding="myScrollPane">
|
||||
<constraints>
|
||||
<splitpane position="left"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<minimumSize width="21" height="200"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1fb9d" class="com.intellij.ui.table.JBTable" binding="myTable">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<intercellSpacing width="0" height="0"/>
|
||||
<showHorizontalLines value="false"/>
|
||||
<showVerticalLines value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</splitpane>
|
||||
<grid id="bc3dc" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="d29c8" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<splitpane id="2c9d2" binding="mySplitPanel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<orientation value="0"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fd341" class="com.intellij.ui.components.JBLabel" binding="mySourceDirLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<grid id="31406" binding="myDiffPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<splitpane position="right"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="ee75f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="mySourceDirField">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="23086" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="cba0d" class="com.intellij.ui.components.JBLabel" binding="myTargetDirLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="cc2ae" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myTargetDirField">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="490e0" binding="myActionsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="6002e" binding="myActionsCenterPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="2" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="etched"/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<scrollpane id="90582" class="com.intellij.ui.components.JBScrollPane" binding="myScrollPane">
|
||||
<constraints>
|
||||
<splitpane position="left"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<minimumSize width="21" height="200"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="d0cf4">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="b08b8" binding="myToolBarPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<component id="1fb9d" class="com.intellij.ui.table.JBTable" binding="myTable">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<intercellSpacing width="0" height="0"/>
|
||||
<showHorizontalLines value="false"/>
|
||||
<showVerticalLines value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</splitpane>
|
||||
<grid id="bc3dc" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="d29c8" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fd341" class="com.intellij.ui.components.JBLabel" binding="mySourceDirLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="97b9b" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</component>
|
||||
<component id="ee75f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="mySourceDirField">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="23086" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="cba0d" class="com.intellij.ui.components.JBLabel" binding="myTargetDirLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="cc2ae" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myTargetDirField">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="490e0" binding="myActionsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="6002e" binding="myActionsCenterPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="2" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="etched"/>
|
||||
<children>
|
||||
<component id="51b76" class="javax.swing.JComboBox" binding="myFileFilter">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<editable value="true"/>
|
||||
<model>
|
||||
<item value="*.*"/>
|
||||
</model>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5d686" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<labelFor value="51b76"/>
|
||||
<text value="Filter:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="d0cf4">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="b08b8" binding="myToolBarPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="97b9b" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="51b76" class="javax.swing.JComboBox" binding="myFileFilter">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<editable value="true"/>
|
||||
<model>
|
||||
<item value="*.*"/>
|
||||
</model>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5d686" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints border-constraint="West"/>
|
||||
<properties>
|
||||
<labelFor value="51b76"/>
|
||||
<text value="Filter:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -21,10 +21,13 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.diff.impl.dir.actions.DirDiffToolbarActions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.LoadingDecorator;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -32,8 +35,11 @@ import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -52,6 +58,7 @@ public class DirDiffPanel {
|
||||
private JComboBox myFileFilter;
|
||||
private JPanel myToolBarPanel;
|
||||
private JBScrollPane myScrollPane;
|
||||
private JPanel myRootPanel;
|
||||
private final DirDiffTableModel myModel;
|
||||
public JLabel myErrorLabel;
|
||||
private final DirDiffDialog myDialog;
|
||||
@@ -67,7 +74,10 @@ public class DirDiffPanel {
|
||||
myTargetDirField.setText(model.getTargetDir().getPath());
|
||||
mySourceDirLabel.setIcon(model.getSourceDir().getIcon());
|
||||
myTargetDirLabel.setIcon(model.getTargetDir().getIcon());
|
||||
myModel.setTable(myTable);
|
||||
myModel.setDisposableParent(dirDiffDialog.getDisposable());
|
||||
myTable.setModel(myModel);
|
||||
|
||||
final DirDiffTableCellRenderer renderer = new DirDiffTableCellRenderer(myTable);
|
||||
myTable.setDefaultRenderer(Object.class, renderer);
|
||||
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
@@ -148,8 +158,41 @@ public class DirDiffPanel {
|
||||
final TableColumn operationColumn = columnModel.getColumn((columnModel.getColumnCount() - 1) / 2);
|
||||
operationColumn.setMaxWidth(25);
|
||||
operationColumn.setMinWidth(25);
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
final String name = myModel.getColumnName(i);
|
||||
final TableColumn column = columnModel.getColumn(i);
|
||||
if (DirDiffTableModel.COLUMN_DATE.equals(name)) {
|
||||
column.setMaxWidth(90);
|
||||
column.setMinWidth(90);
|
||||
} else if (DirDiffTableModel.COLUMN_SIZE.equals(name)) {
|
||||
column.setMaxWidth(120);
|
||||
column.setMinWidth(120);
|
||||
}
|
||||
}
|
||||
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("DirDiff", new DirDiffToolbarActions(myModel), true);
|
||||
myToolBarPanel.add(toolbar.getComponent(), BorderLayout.CENTER);
|
||||
final LoadingDecorator decorator = new LoadingDecorator(myComponent, dirDiffDialog.getDisposable(), -1) {
|
||||
@Override
|
||||
protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
|
||||
final NonOpaquePanel panel = super.customizeLoadingLayer(parent, text, icon);
|
||||
final Font font = text.getFont();
|
||||
text.setFont(font.deriveFont(font.getStyle(), font.getSize() + 6));
|
||||
text.setForeground(new Color(0,0,0,150));
|
||||
return panel;
|
||||
}
|
||||
};
|
||||
//mySplitPanel.setTopComponent(decorator.getComponent());
|
||||
decorator.getComponent().setMinimumSize(new Dimension(400, 100));
|
||||
myTable.putClientProperty(myModel.DECORATOR, decorator);
|
||||
myTable.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
myTable.removeComponentListener(this);
|
||||
myModel.reloadModel();
|
||||
}
|
||||
});
|
||||
myRootPanel.removeAll();
|
||||
myRootPanel.add(decorator.getComponent(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private JLabel getErrorLabel() {
|
||||
@@ -176,7 +219,7 @@ public class DirDiffPanel {
|
||||
}
|
||||
|
||||
public JComponent getPanel() {
|
||||
return myComponent;
|
||||
return myRootPanel;
|
||||
}
|
||||
|
||||
public JBTable getTable() {
|
||||
@@ -184,6 +227,21 @@ public class DirDiffPanel {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myModel.stopUpdating();
|
||||
clearDiffPanel();
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
final AtomicBoolean callUpdate = new AtomicBoolean(true);
|
||||
myRootPanel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
if (callUpdate.get()) {
|
||||
callUpdate.set(false);
|
||||
myModel.reloadModel();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,21 @@ package com.intellij.openapi.diff.impl.dir;
|
||||
|
||||
import com.intellij.ide.diff.DiffElement;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.LoadingDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -37,61 +44,172 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
private final DirDiffSettings mySettings;
|
||||
private DiffElement mySrc;
|
||||
private DiffElement myTrg;
|
||||
final List<DirDiffElement> myElements = new ArrayList<DirDiffElement>();
|
||||
private boolean myUpdating = false;
|
||||
private DTree myTree;
|
||||
private final List<DirDiffElement> myElements = new ArrayList<DirDiffElement>();
|
||||
private final AtomicBoolean myUpdating = new AtomicBoolean(false);
|
||||
private JBTable myTable;
|
||||
private Disposable myDisposableParent;
|
||||
public String DECORATOR = "DIFF_TABLE_DECORATOR";
|
||||
public volatile AtomicReference<String> text = new AtomicReference<String>(prepareText(""));
|
||||
private Updater updater;
|
||||
|
||||
|
||||
public static final String EMPTY_STRING = " ";
|
||||
|
||||
public DirDiffTableModel(Project project, DiffElement src, DiffElement trg, ProgressIndicator indicator, DirDiffSettings settings) {
|
||||
public void stopUpdating() {
|
||||
if (myUpdating.get()) {
|
||||
myUpdating.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyRemove() {
|
||||
myUpdating.set(true);
|
||||
final Iterator<DirDiffElement> i = myElements.iterator();
|
||||
while(i.hasNext()) {
|
||||
final DType type = i.next().getType();
|
||||
switch (type) {
|
||||
case SOURCE:
|
||||
if (!mySettings.showNewOnSource) i.remove();
|
||||
break;
|
||||
case TARGET:
|
||||
if (!mySettings.showNewOnTarget) i.remove();
|
||||
break;
|
||||
case SEPARATOR:
|
||||
break;
|
||||
case CHANGED:
|
||||
if (!mySettings.showDifferent) i.remove();
|
||||
break;
|
||||
case EQUAL:
|
||||
if (!mySettings.showEqual) i.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean sep = true;
|
||||
for (int j = myElements.size() - 1; j >= 0; j--) {
|
||||
if (myElements.get(j).isSeparator()) {
|
||||
if (sep) {
|
||||
myElements.remove(j);
|
||||
} else {
|
||||
sep = true;
|
||||
}
|
||||
} else {
|
||||
sep = false;
|
||||
}
|
||||
}
|
||||
fireTableDataChanged();
|
||||
myUpdating.set(false);
|
||||
}
|
||||
|
||||
private static String prepareText(String text) {
|
||||
final int LEN = EMPTY_STRING.length();
|
||||
String right;
|
||||
if (text == null) {
|
||||
right = EMPTY_STRING;
|
||||
} else if (text.length() == LEN) {
|
||||
right = text;
|
||||
} else if (text.length() < LEN) {
|
||||
right = text + EMPTY_STRING.substring(0, LEN - text.length());
|
||||
} else {
|
||||
right = "..." + text.substring(text.length() - LEN + 2);
|
||||
}
|
||||
return "Loading... " + right;
|
||||
}
|
||||
|
||||
public DirDiffTableModel(Project project, DiffElement src, DiffElement trg, DirDiffSettings settings) {
|
||||
myProject = project;
|
||||
mySettings = settings;
|
||||
mySrc = src;
|
||||
myTrg = trg;
|
||||
reloadModel(indicator);
|
||||
}
|
||||
|
||||
public void reloadModel(ProgressIndicator indicator) {
|
||||
myUpdating = true;
|
||||
clear();
|
||||
final DTree tree = new DTree(null, "", true);
|
||||
scan(mySrc, tree, true);
|
||||
scan(myTrg, tree, false);
|
||||
public void reloadModel() {
|
||||
myUpdating.set(true);
|
||||
final LoadingDecorator decorator = getDecorator();
|
||||
decorator.startLoading(false);
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
updater = new Updater(decorator, 100);
|
||||
updater.start();
|
||||
myTree = new DTree(null, "", true);
|
||||
scan(mySrc, myTree, true);
|
||||
scan(myTrg, myTree, false);
|
||||
|
||||
tree.setSource(mySrc);
|
||||
tree.setTarget(myTrg);
|
||||
tree.update(mySettings);
|
||||
tree.updateVisibility(mySettings);
|
||||
|
||||
myElements.clear();
|
||||
fillElements(tree);
|
||||
fireTableDataChanged();
|
||||
myUpdating = false;
|
||||
myTree.setSource(mySrc);
|
||||
myTree.setTarget(myTrg);
|
||||
myTree.update(mySettings);
|
||||
applySettings();
|
||||
}
|
||||
catch (Exception e) {//
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fillElements(DTree tree) {
|
||||
private LoadingDecorator getDecorator() {
|
||||
return (LoadingDecorator)myTable.getClientProperty(DECORATOR);
|
||||
}
|
||||
|
||||
public void applySettings() {
|
||||
if (! myUpdating.get()) myUpdating.set(true);
|
||||
if (!getDecorator().isLoading()) {
|
||||
getDecorator().startLoading(false);
|
||||
if (updater == null) {
|
||||
updater = new Updater(getDecorator(), 100);
|
||||
updater.start();
|
||||
}
|
||||
}
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
myTree.updateVisibility(mySettings);
|
||||
final ArrayList<DirDiffElement> elements = new ArrayList<DirDiffElement>();
|
||||
fillElements(myTree, elements);
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
clear();
|
||||
myElements.addAll(elements);
|
||||
myUpdating.set(false);
|
||||
fireTableDataChanged();
|
||||
DirDiffTableModel.this.text.set("");
|
||||
if (getDecorator().isLoading()) {
|
||||
getDecorator().stopLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fillElements(DTree tree, List<DirDiffElement> elements) {
|
||||
if (!myUpdating.get()) return;
|
||||
boolean separatorAdded = tree.getParent() == null;
|
||||
text.set(prepareText(tree.getPath()));
|
||||
for (DTree child : tree.getChildren()) {
|
||||
if (!myUpdating.get()) return;
|
||||
if (!child.isContainer()) {
|
||||
if (child.isVisible()) {
|
||||
if (!separatorAdded) {
|
||||
myElements.add(DirDiffElement.createDirElement(tree.getSource(), tree.getTarget(), tree.getPath()));
|
||||
elements.add(DirDiffElement.createDirElement(tree.getSource(), tree.getTarget(), tree.getPath()));
|
||||
separatorAdded = true;
|
||||
}
|
||||
switch (child.getType()) {
|
||||
case SOURCE:
|
||||
myElements.add(DirDiffElement.createSourceOnly(child.getSource()));
|
||||
elements.add(DirDiffElement.createSourceOnly(child.getSource()));
|
||||
break;
|
||||
case TARGET:
|
||||
myElements.add(DirDiffElement.createTargetOnly(child.getTarget()));
|
||||
elements.add(DirDiffElement.createTargetOnly(child.getTarget()));
|
||||
break;
|
||||
case CHANGED:
|
||||
myElements.add(DirDiffElement.createChange(child.getSource(), child.getTarget()));
|
||||
elements.add(DirDiffElement.createChange(child.getSource(), child.getTarget()));
|
||||
break;
|
||||
case EQUAL:
|
||||
myElements.add(DirDiffElement.createEqual(child.getSource(), child.getTarget()));
|
||||
elements.add(DirDiffElement.createEqual(child.getSource(), child.getTarget()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fillElements(child);
|
||||
fillElements(child, elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,10 +222,17 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
}
|
||||
}
|
||||
|
||||
private static void scan(DiffElement element, DTree root, boolean source) {
|
||||
public void setDisposableParent(Disposable parent) {
|
||||
myDisposableParent = parent;
|
||||
}
|
||||
|
||||
private void scan(DiffElement element, DTree root, boolean source) {
|
||||
if (!myUpdating.get()) return;
|
||||
if (element.isContainer()) {
|
||||
try {
|
||||
text.set(prepareText(element.getPath()));
|
||||
for (DiffElement child : element.getChildren()) {
|
||||
if (!myUpdating.get()) return;
|
||||
scan(child, root.addChild(child, source), source);
|
||||
}
|
||||
}
|
||||
@@ -146,6 +271,14 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
return count;
|
||||
}
|
||||
|
||||
public JBTable getTable() {
|
||||
return myTable;
|
||||
}
|
||||
|
||||
public void setTable(JBTable table) {
|
||||
myTable = table;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
@@ -218,6 +351,41 @@ public class DirDiffTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public boolean isUpdating() {
|
||||
return myUpdating;
|
||||
return myUpdating.get();
|
||||
}
|
||||
|
||||
class Updater extends Thread {
|
||||
private final LoadingDecorator myDecorator;
|
||||
private final int mySleep;
|
||||
|
||||
Updater(LoadingDecorator decorator, int sleep) {
|
||||
super("Loading Updater");
|
||||
myDecorator = decorator;
|
||||
mySleep = sleep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (myDecorator.isLoading()) {
|
||||
try {
|
||||
Thread.sleep(mySleep);
|
||||
}
|
||||
catch (InterruptedException e) {//
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String s = text.get();
|
||||
if (s != null && myDecorator.isLoading()) {
|
||||
myDecorator.setLoadingText(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
updater = new Updater(myDecorator, mySleep);
|
||||
updater.start();
|
||||
} else {
|
||||
updater = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,15 @@ public abstract class DirDiffAction extends ToggleAction implements DirDiffIcons
|
||||
@Override
|
||||
public final void setSelected(AnActionEvent e, boolean state) {
|
||||
updateState(state);
|
||||
getModel().reloadModel(null);
|
||||
if (this.getClass() == RefreshDirDiffAction.class) {
|
||||
getModel().reloadModel();
|
||||
} else {
|
||||
if (state) {
|
||||
getModel().applySettings();
|
||||
} else {
|
||||
getModel().applyRemove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -133,7 +133,7 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
indicator.pushState();
|
||||
|
||||
try {
|
||||
final GroovyToJavaGenerator generator = new GroovyToJavaGenerator(myProject, toCompile, false);
|
||||
final GroovyToJavaGenerator generator = new GroovyToJavaGenerator(myProject, new HashSet<VirtualFile>(toCompile), false);
|
||||
for (int i = 0; i < toCompile.size(); i++) {
|
||||
indicator.setFraction((double)i / toCompile.size());
|
||||
|
||||
@@ -212,21 +212,21 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
LOG.debug("Generating stubs for " + item.getName() + "...");
|
||||
}
|
||||
|
||||
final Map<String, String> output = ApplicationManager.getApplication().runReadAction(new Computable<Map<String, String>>() {
|
||||
public Map<String, String> compute() {
|
||||
final Map<String, CharSequence> output = ApplicationManager.getApplication().runReadAction(new Computable<Map<String, CharSequence>>() {
|
||||
public Map<String, CharSequence> compute() {
|
||||
return generator.generateStubs((GroovyFile)PsiManager.getInstance(project).findFile(item));
|
||||
}
|
||||
});
|
||||
return writeStubs(outputRootDirectory, output, item);
|
||||
}
|
||||
|
||||
private static List<VirtualFile> writeStubs(VirtualFile outputRootDirectory, Map<String, String> output, VirtualFile src) {
|
||||
private static List<VirtualFile> writeStubs(VirtualFile outputRootDirectory, Map<String, CharSequence> output, VirtualFile src) {
|
||||
final ArrayList<VirtualFile> stubs = CollectionFactory.arrayList();
|
||||
for (String relativePath : output.keySet()) {
|
||||
final File stubFile = new File(outputRootDirectory.getPath(), relativePath);
|
||||
FileUtil.createIfDoesntExist(stubFile);
|
||||
try {
|
||||
FileUtil.writeToFile(stubFile, output.get(relativePath).getBytes(src.getCharset()));
|
||||
FileUtil.writeToFile(stubFile, output.get(relativePath).toString().getBytes(src.getCharset()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
|
||||
+2
-3
@@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
@@ -70,7 +69,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum
|
||||
if (!(nameElement instanceof LeafPsiElement)) return null;
|
||||
|
||||
IElementType elementType = ((LeafPsiElement)nameElement).getElementType();
|
||||
if (elementType != GroovyTokenTypes.mIDENT && !CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getPsiTypeName(elementType))) {
|
||||
if (elementType != GroovyTokenTypes.mIDENT && !CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elementType))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -166,7 +165,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum
|
||||
return element.getText();
|
||||
}
|
||||
|
||||
if (CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getPsiTypeName(elemType))) {
|
||||
if (CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elemType))) {
|
||||
return GrStringUtil.removeQuotes(element.getText());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -428,7 +428,7 @@ public class TypesUtil {
|
||||
if (elemType == kNULL) {
|
||||
return PsiType.NULL;
|
||||
}
|
||||
final String typeName = getPsiTypeName(elemType);
|
||||
final String typeName = getBoxedTypeName(elemType);
|
||||
if (typeName != null) {
|
||||
return createTypeByFQClassName(typeName, context);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class TypesUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getPsiTypeName(IElementType elemType) {
|
||||
public static String getBoxedTypeName(IElementType elemType) {
|
||||
return ourPrimitiveTypesToClassNames.get(elemType);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -162,8 +162,8 @@ public class GrCodeReferenceElementImpl extends GrReferenceElementImpl<GrCodeRef
|
||||
if (target instanceof PsiClass) {
|
||||
final PsiClass aClass = (PsiClass)target;
|
||||
String name = aClass.getQualifiedName();
|
||||
if (name == null) {
|
||||
name = aClass.getName(); //?
|
||||
if (name == null) { //parameter types don't have qualified name
|
||||
name = aClass.getName();
|
||||
}
|
||||
final PsiType[] types = getTypeArguments();
|
||||
if (types.length == 0) return name;
|
||||
|
||||
+5
-6
@@ -26,7 +26,7 @@ import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
@@ -57,11 +57,10 @@ public class GroovyPatterns extends PsiJavaPatterns {
|
||||
return groovyLiteralExpression(null);
|
||||
}
|
||||
|
||||
public static GroovyElementPattern.Capture<GrLiteral> groovyLiteralExpression(final ElementPattern value) {
|
||||
public static GroovyElementPattern.Capture<GrLiteral> groovyLiteralExpression(@Nullable final ElementPattern value) {
|
||||
return new GroovyElementPattern.Capture<GrLiteral>(new InitialPatternCondition<GrLiteral>(GrLiteral.class) {
|
||||
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
|
||||
return o instanceof GrLiteral
|
||||
&& (value == null || value.accepts(((GrLiteral)o).getValue(), context));
|
||||
return o instanceof GrLiteral && (value == null || value.accepts(((GrLiteral)o).getValue(), context));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -103,8 +102,8 @@ public class GroovyPatterns extends PsiJavaPatterns {
|
||||
PsiElement nameElement = ((GrArgumentLabel)o).getNameElement();
|
||||
if (nameElement instanceof LeafPsiElement) {
|
||||
IElementType elementType = ((LeafPsiElement)nameElement).getElementType();
|
||||
if (elementType == GroovyElementTypes.mIDENT ||
|
||||
CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getPsiTypeName(elementType))) {
|
||||
if (elementType == GroovyTokenTypes.mIDENT ||
|
||||
CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elementType))) {
|
||||
return namePattern == null || namePattern.accepts(((GrArgumentLabel)o).getName());
|
||||
}
|
||||
}
|
||||
|
||||
+590
@@ -0,0 +1,590 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightMethodBuilder;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrConstructor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GrClassImplUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.refactoring.convertToJava.GenerationUtil.writeType;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class ClassGenerator {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.convertToJava.ClassGenerator");
|
||||
|
||||
private Project myProject;
|
||||
private ClassNameProvider classNameProvider;
|
||||
|
||||
public ClassGenerator(Project project, ClassNameProvider classNameProvider) {
|
||||
myProject = project;
|
||||
this.classNameProvider = classNameProvider;
|
||||
}
|
||||
|
||||
private static void writePackageStatement(StringBuilder text, GrPackageDefinition packageDefinition) {
|
||||
if (packageDefinition != null) {
|
||||
text.append("package ");
|
||||
text.append(packageDefinition.getPackageName());
|
||||
text.append(";");
|
||||
text.append("\n");
|
||||
text.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTypeDefinition(StringBuilder text, @NotNull final PsiClass typeDefinition, boolean toplevel) {
|
||||
final boolean isScript = typeDefinition instanceof GroovyScriptClass;
|
||||
|
||||
final GroovyFile containingFile = (GroovyFile)typeDefinition.getContainingFile();
|
||||
writePackageStatement(text, containingFile.getPackageDefinition());
|
||||
|
||||
boolean isEnum = typeDefinition.isEnum();
|
||||
boolean isAnnotationType = typeDefinition.isAnnotationType();
|
||||
boolean isInterface = !isAnnotationType && typeDefinition.isInterface();
|
||||
boolean isClassDef = !isInterface && !isEnum && !isAnnotationType && !isScript;
|
||||
|
||||
GenerationUtil.writeClassModifiers(text, typeDefinition.getModifierList(), typeDefinition.isInterface(), toplevel);
|
||||
|
||||
if (isInterface) {
|
||||
text.append("interface");
|
||||
}
|
||||
else if (isEnum) {
|
||||
text.append("enum");
|
||||
}
|
||||
else if (isAnnotationType) {
|
||||
text.append("@interface");
|
||||
}
|
||||
else {
|
||||
text.append("class");
|
||||
}
|
||||
|
||||
text.append(" ").append(typeDefinition.getName());
|
||||
|
||||
appendTypeParameters(text, typeDefinition);
|
||||
|
||||
text.append(" ");
|
||||
|
||||
if (isScript) {
|
||||
text.append("extends groovy.lang.Script ");
|
||||
}
|
||||
else if (!isEnum && !isAnnotationType) {
|
||||
final PsiClassType[] extendsClassesTypes = typeDefinition.getExtendsListTypes();
|
||||
|
||||
if (extendsClassesTypes.length > 0) {
|
||||
|
||||
text.append("extends ");
|
||||
writeType(text, extendsClassesTypes[0], typeDefinition, classNameProvider);
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
final Collection<PsiClassType> implementsTypes = new LinkedHashSet<PsiClassType>();
|
||||
Collections.addAll(implementsTypes, typeDefinition.getImplementsListTypes());
|
||||
/*for (PsiClass aClass : collectDelegateTypes(typeDefinition)) {
|
||||
if (aClass.isInterface()) {
|
||||
implementsTypes.add(JavaPsiFacade.getElementFactory(myProject).createType(aClass));
|
||||
} else {
|
||||
Collections.addAll(implementsTypes, aClass.getImplementsListTypes());
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!implementsTypes.isEmpty()) {
|
||||
text.append(isInterface ? "extends " : "implements ");
|
||||
for (PsiClassType implementsType : implementsTypes) {
|
||||
writeType(text, implementsType, typeDefinition, classNameProvider);
|
||||
text.append(", ");
|
||||
}
|
||||
if (implementsTypes.size() > 0) text.delete(text.length() - 2, text.length());
|
||||
text.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
text.append("{\n");
|
||||
|
||||
if (isEnum) {
|
||||
writeEnumConstants(text, (GrEnumTypeDefinition)typeDefinition);
|
||||
}
|
||||
|
||||
writeAllMethods(text, collectMethods(typeDefinition, isClassDef), typeDefinition);
|
||||
|
||||
if (typeDefinition instanceof GrTypeDefinition) {
|
||||
for (GrMembersDeclaration declaration : ((GrTypeDefinition)typeDefinition).getMemberDeclarations()) {
|
||||
if (declaration instanceof GrVariableDeclaration) {
|
||||
writeVariableDeclarations(text, (GrVariableDeclaration)declaration);
|
||||
}
|
||||
}
|
||||
for (PsiClass inner : typeDefinition.getInnerClasses()) {
|
||||
writeTypeDefinition(text, inner, false);
|
||||
text.append("\n");
|
||||
}
|
||||
}
|
||||
text.append("}");
|
||||
}
|
||||
|
||||
|
||||
private void writeAllMethods(StringBuilder text, Collection<PsiMethod> methods, PsiClass aClass) {
|
||||
Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
|
||||
for (PsiMethod method : methods) {
|
||||
if (!shouldBeGenerated(method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (method instanceof GrConstructor) {
|
||||
writeConstructor(text, (GrConstructor)method, aClass.isEnum());
|
||||
continue;
|
||||
}
|
||||
|
||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (parameters.length > 0) {
|
||||
PsiParameter[] parametersCopy = new PsiParameter[parameters.length];
|
||||
PsiType[] parameterTypes = new PsiType[parameters.length];
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
parametersCopy[i] = parameters[i];
|
||||
parameterTypes[i] = findOutParameterType(parameters[i]);
|
||||
}
|
||||
|
||||
for (int i = parameters.length - 1; i >= 0; i--) {
|
||||
MethodSignature signature =
|
||||
MethodSignatureUtil.createMethodSignature(method.getName(), parameterTypes, method.getTypeParameters(), PsiSubstitutor.EMPTY);
|
||||
if (methodSignatures.add(signature)) {
|
||||
writeMethod(text, method, parametersCopy);
|
||||
text.append('\n');
|
||||
|
||||
}
|
||||
|
||||
PsiParameter parameter = parameters[i];
|
||||
if (!(parameter instanceof GrParameter) || !((GrParameter)parameter).isOptional()) break;
|
||||
parameterTypes = ArrayUtil.remove(parameterTypes, parameterTypes.length - 1);
|
||||
parametersCopy = ArrayUtil.remove(parametersCopy, parametersCopy.length - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
|
||||
if (methodSignatures.add(signature)) {
|
||||
writeMethod(text, method, parameters);
|
||||
text.append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendTypeParameters(StringBuilder text, PsiTypeParameterListOwner typeParameterListOwner) {
|
||||
if (!typeParameterListOwner.hasTypeParameters()) return;
|
||||
|
||||
text.append("<");
|
||||
PsiTypeParameter[] parameters = typeParameterListOwner.getTypeParameters();
|
||||
final PsiTypeParameterList typeParameterList = typeParameterListOwner.getTypeParameterList();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (i > 0) text.append(", ");
|
||||
PsiTypeParameter parameter = parameters[i];
|
||||
text.append(parameter.getName());
|
||||
PsiClassType[] extendsListTypes = parameter.getExtendsListTypes();
|
||||
if (extendsListTypes.length > 0) {
|
||||
text.append(" extends ");
|
||||
for (int j = 0; j < extendsListTypes.length; j++) {
|
||||
if (j > 0) text.append(" & ");
|
||||
writeType(text, extendsListTypes[j], typeParameterList, classNameProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
text.append(">");
|
||||
}
|
||||
|
||||
private void writeParameterList(StringBuilder text, PsiParameter[] parameters) {
|
||||
text.append("(");
|
||||
|
||||
//writes myParameters
|
||||
int i = 0;
|
||||
while (i < parameters.length) {
|
||||
PsiParameter parameter = parameters[i];
|
||||
if (parameter == null) continue;
|
||||
|
||||
if (i > 0) text.append(", "); //append ','
|
||||
writeType(text, findOutParameterType(parameter), parameter, classNameProvider);
|
||||
text.append(" ");
|
||||
text.append(parameter.getName());
|
||||
|
||||
i++;
|
||||
}
|
||||
text.append(")");
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
|
||||
private void writeThrowsList(StringBuilder text, PsiMethod method) {
|
||||
final PsiReferenceList throwsList = method.getThrowsList();
|
||||
final PsiClassType[] exceptions = throwsList.getReferencedTypes();
|
||||
if (exceptions.length > 0) {
|
||||
text.append("throws ");
|
||||
for (int i = 0; i < exceptions.length; i++) {
|
||||
PsiClassType exception = exceptions[i];
|
||||
if (i != 0) {
|
||||
text.append(",");
|
||||
}
|
||||
writeType(text, exception, throwsList, classNameProvider);
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
//todo search for all thrown exceptions from this file methods
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMethodBody(StringBuilder text, PsiMethod method, PsiType retType) {
|
||||
if (classNameProvider.forStubs()) {
|
||||
text.append("{\nreturn ");
|
||||
text.append(GroovyToJavaGenerator.getDefaultValueText(retType.getCanonicalText()));
|
||||
text.append(";\n}");
|
||||
return;
|
||||
}
|
||||
if (method instanceof GrMethod) {
|
||||
final CodeBlockGenerator blockGenerator = new CodeBlockGenerator(text, myProject);
|
||||
final GrOpenBlock block = ((GrMethod)method).getBlock();
|
||||
LOG.assertTrue(block != null);
|
||||
block.accept(blockGenerator);
|
||||
}
|
||||
}
|
||||
|
||||
private PsiType findOutReturnTypeOfMethod(PsiMethod method) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (returnType != null) return returnType;
|
||||
|
||||
if (classNameProvider.forStubs()) return TypesUtil.getJavaLangObject(method);
|
||||
|
||||
final PsiType smartReturnType = org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.getSmartReturnType(method);
|
||||
if (smartReturnType != null) return smartReturnType;
|
||||
|
||||
//todo make smarter. search for usages and infer type from them
|
||||
return TypesUtil.getJavaLangObject(method);
|
||||
//final Collection<PsiReference> collection = MethodReferencesSearch.search(method).findAll();
|
||||
}
|
||||
|
||||
private static PsiType findOutParameterType(PsiParameter parameter) {
|
||||
return parameter.getType(); //todo make smarter
|
||||
}
|
||||
|
||||
|
||||
void writeMethod(StringBuilder text, PsiMethod method, final PsiParameter[] parameters) {
|
||||
if (method == null) return;
|
||||
String name = method.getName();
|
||||
if (!JavaPsiFacade.getInstance(method.getProject()).getNameHelper().isIdentifier(name)) {
|
||||
return; //does not have a java image
|
||||
}
|
||||
|
||||
boolean isAbstract = isAbstractInJava(method);
|
||||
|
||||
PsiModifierList modifierList = method.getModifierList();
|
||||
|
||||
GenerationUtil.writeModifiers(text, modifierList, GenerationUtil.JAVA_MODIFIERS);
|
||||
if (method.hasTypeParameters()) {
|
||||
appendTypeParameters(text, method);
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
//append return type
|
||||
PsiType retType = findOutReturnTypeOfMethod(method);
|
||||
|
||||
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
final List<MethodSignatureBackedByPsiMethod> superSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
|
||||
for (MethodSignatureBackedByPsiMethod superSignature : superSignatures) {
|
||||
final PsiType superType = superSignature.getSubstitutor().substitute(superSignature.getMethod().getReturnType());
|
||||
if (superType != null &&
|
||||
!superType.isAssignableFrom(retType) &&
|
||||
!(PsiUtil.resolveClassInType(superType) instanceof PsiTypeParameter)) {
|
||||
retType = superType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeType(text, retType, method, classNameProvider);
|
||||
text.append(" ");
|
||||
|
||||
text.append(name);
|
||||
|
||||
writeParameterList(text, parameters);
|
||||
|
||||
writeThrowsList(text, method);
|
||||
|
||||
if (!isAbstract) {
|
||||
/************* body **********/
|
||||
writeMethodBody(text, method, retType);
|
||||
}
|
||||
else {
|
||||
text.append(";");
|
||||
}
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
|
||||
private void writeVariableDeclarations(StringBuilder text, GrVariableDeclaration variableDeclaration) {
|
||||
GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
|
||||
|
||||
final GrModifierList modifierList = variableDeclaration.getModifierList();
|
||||
final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(variableDeclaration.getProject()).getNameHelper();
|
||||
for (final GrVariable variable : variableDeclaration.getVariables()) {
|
||||
String name = variable.getName();
|
||||
if (!nameHelper.isIdentifier(name)) {
|
||||
continue; //does not have a java image
|
||||
}
|
||||
|
||||
GenerationUtil.writeModifiers(text, modifierList, GenerationUtil.JAVA_MODIFIERS);
|
||||
|
||||
//type
|
||||
PsiType declaredType =
|
||||
typeElement == null ? PsiType.getJavaLangObject(variable.getManager(), variable.getResolveScope()) : typeElement.getType();
|
||||
final String initializer = GroovyToJavaGenerator.getDefaultValueText(declaredType.getCanonicalText());
|
||||
|
||||
writeType(text, declaredType, variableDeclaration, classNameProvider);
|
||||
text.append(" ").append(name).append(" = ").append(initializer);
|
||||
text.append(";\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void writeEnumConstants(StringBuilder text, GrEnumTypeDefinition enumDefinition) {
|
||||
GrEnumConstant[] enumConstants = enumDefinition.getEnumConstants();
|
||||
for (int i = 0; i < enumConstants.length; i++) {
|
||||
if (i > 0) text.append(", ");
|
||||
GrEnumConstant enumConstant = enumConstants[i];
|
||||
text.append(enumConstant.getName());
|
||||
PsiMethod constructor = enumConstant.resolveMethod();
|
||||
if (constructor != null) {
|
||||
text.append("(");
|
||||
writeStubConstructorInvocation(text, constructor, PsiSubstitutor.EMPTY, enumConstant);
|
||||
text.append(")");
|
||||
}
|
||||
|
||||
GrTypeDefinitionBody block = enumConstant.getAnonymousBlock();
|
||||
if (block != null) {
|
||||
text.append("{\n");
|
||||
for (PsiMethod method : block.getMethods()) {
|
||||
writeMethod(text, method, method.getParameterList().getParameters());
|
||||
}
|
||||
text.append("}");
|
||||
}
|
||||
}
|
||||
text.append(";\n");
|
||||
}
|
||||
|
||||
private static boolean shouldBeGenerated(PsiMethod method) {
|
||||
for (PsiMethod psiMethod : method.findSuperMethods()) {
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
final PsiType type = method.getReturnType();
|
||||
final PsiType superType = psiMethod.getReturnType();
|
||||
if (type != null && superType != null && !superType.isAssignableFrom(type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private Collection<PsiMethod> collectMethods(PsiClass typeDefinition, boolean classDef) {
|
||||
List<PsiMethod> methods = new ArrayList<PsiMethod>();
|
||||
ContainerUtil.addAll(methods, typeDefinition.getMethods());
|
||||
if (classDef && classNameProvider.forStubs()) {
|
||||
final Collection<MethodSignature> toOverride = OverrideImplementUtil.getMethodSignaturesToOverride(typeDefinition);
|
||||
for (MethodSignature signature : toOverride) {
|
||||
if (signature instanceof MethodSignatureBackedByPsiMethod) {
|
||||
final PsiMethod method = ((MethodSignatureBackedByPsiMethod)signature).getMethod();
|
||||
final PsiClass baseClass = method.getContainingClass();
|
||||
if (isAbstractInJava(method) && baseClass != null && typeDefinition.isInheritor(baseClass, true)) {
|
||||
methods.add(mirrorMethod(typeDefinition, method, baseClass, PsiSubstitutor.EMPTY, GenerationUtil.JAVA_MODIFIERS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
|
||||
methods.add(factory.createMethodFromText("public groovy.lang.MetaClass getMetaClass() {}", null));
|
||||
methods.add(factory.createMethodFromText("public void setMetaClass(groovy.lang.MetaClass mc) {}", null));
|
||||
methods.add(factory.createMethodFromText("public Object invokeMethod(String name, Object args) {}", null));
|
||||
methods.add(factory.createMethodFromText("public Object getProperty(String propertyName) {}", null));
|
||||
methods.add(factory.createMethodFromText("public void setProperty(String propertyName, Object newValue) {}", null));
|
||||
}
|
||||
|
||||
if (typeDefinition instanceof GrTypeDefinition) {
|
||||
for (PsiMethod delegatedMethod : GrClassImplUtil.getDelegatedMethods((GrTypeDefinition)typeDefinition)) {
|
||||
methods.add(delegatedMethod);
|
||||
}
|
||||
}
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
||||
private static LightMethodBuilder mirrorMethod(PsiClass typeDefinition,
|
||||
PsiMethod method,
|
||||
PsiClass baseClass,
|
||||
PsiSubstitutor substitutor,
|
||||
String... modifierFilter) {
|
||||
final LightMethodBuilder builder = new LightMethodBuilder(method.getManager(), method.getName());
|
||||
substitutor = substitutor.putAll(TypeConversionUtil.getSuperClassSubstitutor(baseClass, typeDefinition, PsiSubstitutor.EMPTY));
|
||||
for (PsiParameter parameter : method.getParameterList().getParameters()) {
|
||||
builder.addParameter(StringUtil.notNullize(parameter.getName()), substitutor.substitute(findOutParameterType(parameter)));
|
||||
}
|
||||
builder.setReturnType(substitutor.substitute(method.getReturnType()));
|
||||
for (String modifier : modifierFilter) {
|
||||
if (method.hasModifierProperty(modifier)) {
|
||||
builder.addModifier(modifier);
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static boolean isAbstractInJava(PsiMethod method) {
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiClass psiClass = method.getContainingClass();
|
||||
return psiClass != null && GrClassSubstitutor.getSubstitutedClass(psiClass).isInterface();
|
||||
}
|
||||
|
||||
void writeConstructor(final StringBuilder text, final GrConstructor constructor, boolean isEnum) {
|
||||
if (!isEnum) {
|
||||
text.append("public ");
|
||||
//writeModifiers(text, constructor.getModifierList(), JAVA_MODIFIERS);
|
||||
}
|
||||
|
||||
/************* name **********/
|
||||
//append constructor name
|
||||
text.append(constructor.getName());
|
||||
|
||||
/************* parameters **********/
|
||||
GrParameter[] parameterList = constructor.getParameters();
|
||||
|
||||
writeParameterList(text, parameterList);
|
||||
|
||||
final Set<String> throwsTypes = collectThrowsTypes(constructor, new THashSet<PsiMethod>());
|
||||
if (!throwsTypes.isEmpty()) {
|
||||
text.append("throws ").append(StringUtil.join(throwsTypes, ", ")).append(" ");
|
||||
}
|
||||
|
||||
/************* body **********/
|
||||
|
||||
text.append("{\n");
|
||||
final GrConstructorInvocation invocation = constructor.getChainingConstructorInvocation();
|
||||
if (invocation != null) {
|
||||
final GroovyResolveResult resolveResult = resolveChainingConstructor(constructor);
|
||||
if (resolveResult != null) {
|
||||
text.append(invocation.isSuperCall() ? "super(" : "this(");
|
||||
writeStubConstructorInvocation(text, (PsiMethod)resolveResult.getElement(), resolveResult.getSubstitutor(), invocation);
|
||||
text.append(");");
|
||||
}
|
||||
}
|
||||
|
||||
text.append("\n}\n");
|
||||
}
|
||||
|
||||
private Set<String> collectThrowsTypes(GrConstructor constructor, Set<PsiMethod> visited) {
|
||||
final GroovyResolveResult resolveResult = resolveChainingConstructor(constructor);
|
||||
if (resolveResult == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
|
||||
final PsiMethod chainedConstructor = (PsiMethod)resolveResult.getElement();
|
||||
assert chainedConstructor != null;
|
||||
|
||||
if (!visited.add(chainedConstructor)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final Set<String> result = CollectionFactory.newTroveSet(ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
for (PsiClassType type : chainedConstructor.getThrowsList().getReferencedTypes()) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
writeType(builder, substitutor.substitute(type), constructor, classNameProvider);
|
||||
result.add(builder.toString());
|
||||
}
|
||||
|
||||
if (chainedConstructor instanceof GrConstructor) {
|
||||
result.addAll(collectThrowsTypes((GrConstructor)chainedConstructor, visited));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GroovyResolveResult resolveChainingConstructor(GrConstructor constructor) {
|
||||
final GrConstructorInvocation constructorInvocation = constructor.getChainingConstructorInvocation();
|
||||
if (constructorInvocation == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GroovyResolveResult resolveResult = constructorInvocation.resolveConstructorGenerics();
|
||||
if (resolveResult.getElement() != null) {
|
||||
return resolveResult;
|
||||
}
|
||||
|
||||
final GroovyResolveResult[] results = constructorInvocation.multiResolveConstructor();
|
||||
if (results.length > 0) {
|
||||
int i = 0;
|
||||
while (results.length > i + 1) {
|
||||
final PsiMethod candidate = (PsiMethod)results[i].getElement();
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(constructor.getProject()).getResolveHelper();
|
||||
if (candidate != null && candidate != constructor && resolveHelper.isAccessible(candidate, constructorInvocation, null)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return results[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void writeStubConstructorInvocation(StringBuilder text, PsiMethod constructor, PsiSubstitutor substitutor, PsiElement invocation) {
|
||||
final PsiParameter[] superParams = constructor.getParameterList().getParameters();
|
||||
for (int j = 0; j < superParams.length; j++) {
|
||||
if (j > 0) text.append(", ");
|
||||
text.append("(");
|
||||
final PsiType type = findOutParameterType(superParams[j]);
|
||||
writeType(text, substitutor.substitute(type), invocation,classNameProvider);
|
||||
text.append(")").append(GroovyToJavaGenerator.getDefaultValueText(type.getCanonicalText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public interface ClassNameProvider {
|
||||
|
||||
@Nullable
|
||||
String getQualifiedClassName(PsiClass clazz, @Nullable PsiElement context);
|
||||
|
||||
boolean forStubs();
|
||||
}
|
||||
+48
-23
@@ -19,7 +19,11 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.ui.UsageViewDescriptorAdapter;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -27,9 +31,9 @@ import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
|
||||
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -44,6 +48,7 @@ public class ConvertToJavaProcessor extends BaseRefactoringProcessor {
|
||||
myFiles = files;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
|
||||
return new UsageViewDescriptorAdapter() {
|
||||
@@ -69,24 +74,30 @@ public class ConvertToJavaProcessor extends BaseRefactoringProcessor {
|
||||
//private static String
|
||||
@Override
|
||||
protected void performRefactoring(UsageInfo[] usages) {
|
||||
// final GroovyToJavaGenerator generator = new GroovyToJavaGenerator(myProject, Collections.<VirtualFile>emptyList(), true);
|
||||
final HashSet<VirtualFile> allToCompile = new HashSet<VirtualFile>();
|
||||
for (GroovyFile file : myFiles) {
|
||||
allToCompile.add(file.getVirtualFile());
|
||||
}
|
||||
final GroovyToJavaGenerator fileGenerator = new GroovyToJavaGenerator(myProject, allToCompile, true);
|
||||
|
||||
for (GroovyFile file : myFiles) {
|
||||
final PsiDirectory dir = file.getContainingDirectory();
|
||||
LOG.assertTrue(dir != null);
|
||||
final Map<String, CharSequence> map = fileGenerator.generateStubs(file);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : map.keySet()) {
|
||||
builder.append(map.get(s)).append('\n');
|
||||
}
|
||||
|
||||
String fileName = getNewFileName(file);
|
||||
final PsiFile newFile = (PsiFile)file.setName(fileName);
|
||||
final Document document = PsiDocumentManager.getInstance(myProject).getDocument(newFile);
|
||||
LOG.assertTrue(document != null);
|
||||
document.setText(builder);
|
||||
}
|
||||
|
||||
|
||||
final PsiFile[] files = dir.getFiles();
|
||||
Set<String> fileNames = new HashSet<String>();
|
||||
for (PsiFile psiFile : files) {
|
||||
fileNames.add(psiFile.getName());
|
||||
}
|
||||
String prefix = FileUtil.getNameWithoutExtension(file.getName());
|
||||
String fileName = prefix + ".java";
|
||||
int index = 1;
|
||||
while (fileNames.contains(fileName)) {
|
||||
fileName = prefix + index + ".java";
|
||||
}
|
||||
/*
|
||||
for (GroovyFile file : myFiles) {
|
||||
|
||||
final Project project = file.getProject();
|
||||
|
||||
GrTopStatement[] statements = file.getTopStatements();
|
||||
@@ -96,17 +107,31 @@ public class ConvertToJavaProcessor extends BaseRefactoringProcessor {
|
||||
statement.accept(generator);
|
||||
builder.append("\n");
|
||||
}
|
||||
|
||||
String fileName = getNewFileName(file);
|
||||
final PsiFile newFile = (PsiFile)file.setName(fileName);
|
||||
final Document document = PsiDocumentManager.getInstance(project).getDocument(newFile);
|
||||
document.setText(builder);
|
||||
/*final PsiFile created = PsiFileFactory.getInstance(project)
|
||||
.createFileFromText(file.getScriptClass().getName() + ".java", StdLanguages.JAVA, builder.toString());
|
||||
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
|
||||
file.delete();
|
||||
dir.add(created);*/
|
||||
//QuickfixUtil.positionCursor(project, created, created.getFirstChild());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static String getNewFileName(GroovyFile file) {
|
||||
final PsiDirectory dir = file.getContainingDirectory();
|
||||
LOG.assertTrue(dir != null);
|
||||
|
||||
|
||||
final PsiFile[] files = dir.getFiles();
|
||||
Set<String> fileNames = new HashSet<String>();
|
||||
for (PsiFile psiFile : files) {
|
||||
fileNames.add(psiFile.getName());
|
||||
}
|
||||
String prefix = FileUtil.getNameWithoutExtension(file.getName());
|
||||
String fileName = prefix + ".java";
|
||||
int index = 1;
|
||||
while (fileNames.contains(fileName)) {
|
||||
fileName = prefix + index + ".java";
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-27
@@ -28,7 +28,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
@@ -554,8 +553,6 @@ public class ExpressionGenerator extends Generator {
|
||||
else {
|
||||
builder.append(value);
|
||||
}
|
||||
|
||||
//todo replace with character in some cases
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -714,28 +711,10 @@ public class ExpressionGenerator extends Generator {
|
||||
typeElement.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayTypeElement(GrArrayTypeElement typeElement) {
|
||||
//todo
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBuiltinTypeElement(GrBuiltInTypeElement typeElement) {
|
||||
//todo
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClassTypeElement(GrClassTypeElement typeElement) {
|
||||
//todo
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBuiltinTypeClassExpression(GrBuiltinTypeClassExpression expression) {
|
||||
final IElementType type = expression.getFirstChild().getNode().getElementType();
|
||||
final String boxed = TypesUtil.getPsiTypeName(type);
|
||||
final String boxed = TypesUtil.getBoxedTypeName(type);
|
||||
builder.append(boxed).append(".class");
|
||||
}
|
||||
|
||||
@@ -784,7 +763,7 @@ public class ExpressionGenerator extends Generator {
|
||||
GrClosableBlock[] closures,
|
||||
PsiSubstitutor substitutor,
|
||||
GroovyPsiElement context) {
|
||||
if (method instanceof GrGdkMethod && !method.hasModifierProperty(GrModifier.STATIC)) {
|
||||
if (method instanceof GrGdkMethod && !method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (caller == null) {
|
||||
caller = factory.createExpressionFromText("this", context);
|
||||
}
|
||||
@@ -795,8 +774,7 @@ public class ExpressionGenerator extends Generator {
|
||||
return;
|
||||
}
|
||||
|
||||
//todo check for private method?
|
||||
if (method.hasModifierProperty(GrModifier.STATIC)) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
builder.append(containingClass.getQualifiedName()).append(".");
|
||||
@@ -817,7 +795,6 @@ public class ExpressionGenerator extends Generator {
|
||||
|
||||
@Override
|
||||
public void visitListOrMap(GrListOrMap listOrMap) {
|
||||
//todo infer type parameters from context if possible
|
||||
final PsiType type = listOrMap.getType();
|
||||
|
||||
//can be PsiArrayType or GrLiteralClassType
|
||||
@@ -825,7 +802,7 @@ public class ExpressionGenerator extends Generator {
|
||||
|
||||
if (listOrMap.isMap()) {
|
||||
String varName = generateMapVariableDeclaration(listOrMap, type);
|
||||
generateMapElementInsertions(listOrMap, varName); //todo generate array if possible
|
||||
generateMapElementInsertions(listOrMap, varName);
|
||||
builder.append(varName);
|
||||
}
|
||||
else {
|
||||
|
||||
+112
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
@@ -27,6 +28,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlo
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.refactoring.DefaultGroovyVariableNameValidator;
|
||||
@@ -59,6 +61,106 @@ public class GenerationUtil {
|
||||
builder.append(type.getCanonicalText()); //todo make smarter.
|
||||
}
|
||||
|
||||
public static void writeType(final StringBuilder builder,
|
||||
final PsiType type,
|
||||
final PsiElement context,
|
||||
final ClassNameProvider classNameProvider) {
|
||||
if (type instanceof PsiPrimitiveType) {
|
||||
builder.append(type.getCanonicalText());
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean acceptEllipsis = isLastParameter(context);
|
||||
|
||||
type.accept(new PsiTypeVisitor<Object>() {
|
||||
@Override
|
||||
public Object visitEllipsisType(PsiEllipsisType ellipsisType) {
|
||||
final PsiType componentType = ellipsisType.getComponentType();
|
||||
componentType.accept(this);
|
||||
if (acceptEllipsis) {
|
||||
builder.append("...");
|
||||
}
|
||||
else {
|
||||
builder.append("[]");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitPrimitiveType(PsiPrimitiveType primitiveType) {
|
||||
if (classNameProvider.forStubs()) {
|
||||
builder.append(primitiveType.getCanonicalText());
|
||||
return this;
|
||||
}
|
||||
final PsiType boxed = TypesUtil.boxPrimitiveType(primitiveType, context.getManager(), context.getResolveScope());
|
||||
boxed.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitArrayType(PsiArrayType arrayType) {
|
||||
arrayType.getComponentType().accept(this);
|
||||
builder.append("[]");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitClassType(PsiClassType classType) {
|
||||
final PsiType[] parameters = classType.getParameters();
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass == null) {
|
||||
builder.append(classType.getClassName());
|
||||
}
|
||||
else {
|
||||
final String qname = classNameProvider.getQualifiedClassName(psiClass, context);
|
||||
builder.append(qname);
|
||||
}
|
||||
writeTypeParameters(builder, parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
|
||||
capturedWildcardType.getWildcard().accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitWildcardType(PsiWildcardType wildcardType) {
|
||||
builder.append("?");
|
||||
PsiType bound = wildcardType.getBound();
|
||||
if (bound == null) return this;
|
||||
if (wildcardType.isExtends()) {
|
||||
builder.append(" extends");
|
||||
}
|
||||
else {
|
||||
builder.append(" super ");
|
||||
}
|
||||
bound.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitDisjunctionType(PsiDisjunctionType disjunctionType) {
|
||||
//todo
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitType(PsiType type) {
|
||||
//todo
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isLastParameter(PsiElement context) {
|
||||
final PsiElement parent = context.getParent();
|
||||
return context instanceof PsiParameter &&
|
||||
parent instanceof PsiParameterList &&
|
||||
((PsiParameterList)parent).getParameterIndex((PsiParameter)context) == ((PsiParameterList)parent).getParametersCount() - 1;
|
||||
}
|
||||
|
||||
private static void writeTypeParameters(StringBuilder builder, PsiType[] parameters) {
|
||||
if (parameters.length == 0) return;
|
||||
|
||||
@@ -234,4 +336,14 @@ public class GenerationUtil {
|
||||
writer.writeStatement(statementBuilder, statementContext);
|
||||
writeStatement(builder, statementBuilder, statement, statementContext);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiClass findAccessibleSuperClass(@NotNull PsiElement context, @NotNull PsiClass initialClass) {
|
||||
PsiClass curClass = initialClass;
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper();
|
||||
while (curClass != null && !resolveHelper.isAccessible(curClass, context, null)) {
|
||||
curClass = curClass.getSuperClass();
|
||||
}
|
||||
return curClass;
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GeneratorClassNameProvider implements ClassNameProvider {
|
||||
|
||||
@Override
|
||||
public String getQualifiedClassName(PsiClass psiClass, @Nullable PsiElement context) {
|
||||
if (context != null && psiClass != null) {
|
||||
psiClass = GenerationUtil.findAccessibleSuperClass(context, psiClass);
|
||||
}
|
||||
if (psiClass == null) {
|
||||
return CommonClassNames.JAVA_LANG_OBJECT;
|
||||
}
|
||||
|
||||
final String name = psiClass.getQualifiedName();
|
||||
if (name != null) return name;
|
||||
return psiClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forStubs() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+35
-645
@@ -15,48 +15,21 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightMethodBuilder;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrConstructor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GrClassImplUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -80,31 +53,24 @@ public class GroovyToJavaGenerator {
|
||||
typesToInitialValues.put("void", "");
|
||||
}
|
||||
|
||||
private final List<VirtualFile> myAllToCompile;
|
||||
private final Set<VirtualFile> myAllToCompile;
|
||||
private final Project myProject;
|
||||
|
||||
private final boolean fullConversion;
|
||||
|
||||
public GroovyToJavaGenerator(Project project, List<VirtualFile> allToCompile, boolean fullConversion) {
|
||||
public GroovyToJavaGenerator(Project project, Set<VirtualFile> allToCompile, boolean fullConversion) {
|
||||
myProject = project;
|
||||
myAllToCompile = allToCompile;
|
||||
this.fullConversion = fullConversion;
|
||||
}
|
||||
|
||||
public Map<String, String> generateStubs(GroovyFile file) {
|
||||
GrTopStatement[] statements = getTopStatementsInReadAction(file);
|
||||
|
||||
GrPackageDefinition packageDefinition = null;
|
||||
if (statements.length > 0 && statements[0] instanceof GrPackageDefinition) {
|
||||
packageDefinition = (GrPackageDefinition) statements[0];
|
||||
}
|
||||
|
||||
public Map<String, CharSequence> generateStubs(GroovyFile file) {
|
||||
Set<String> classNames = new THashSet<String>();
|
||||
for (final GrTypeDefinition typeDefinition : file.getTypeDefinitions()) {
|
||||
classNames.add(typeDefinition.getName());
|
||||
}
|
||||
|
||||
final Map<String, String> output = new LinkedHashMap<String, String>();
|
||||
final Map<String, CharSequence> output = new LinkedHashMap<String, CharSequence>();
|
||||
|
||||
if (file.isScript()) {
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
@@ -114,17 +80,34 @@ public class GroovyToJavaGenerator {
|
||||
!classNames.contains(StringUtil.decapitalize(fileDefinitionName))) {
|
||||
final PsiClass scriptClass = file.getScriptClass();
|
||||
if (scriptClass != null) {
|
||||
generateClassStub(scriptClass, packageDefinition, output);
|
||||
generateClassStub(scriptClass, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final GrTypeDefinition typeDefinition : file.getTypeDefinitions()) {
|
||||
generateClassStub(GrClassSubstitutor.getSubstitutedClass(typeDefinition), packageDefinition, output);
|
||||
generateClassStub(GrClassSubstitutor.getSubstitutedClass(typeDefinition), output);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private void generateClassStub(PsiClass clazz, Map<String, CharSequence> output) {
|
||||
final CharSequence text = generateClass(clazz);
|
||||
final String filename = getFileNameForClass(clazz);
|
||||
output.put(filename, text);
|
||||
}
|
||||
|
||||
private String getFileNameForClass(PsiClass clazz) {
|
||||
if (fullConversion) {
|
||||
return clazz.getName() + ".java";
|
||||
}
|
||||
else {
|
||||
final PsiFile containingFile = clazz.getContainingFile();
|
||||
final GrPackageDefinition packageDefinition = ((GroovyFile)containingFile).getPackageDefinition();
|
||||
return getPackageDirectory(packageDefinition) + clazz.getName() + ".java";
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPackageDirectory(@Nullable GrPackageDefinition packageDefinition) {
|
||||
if (packageDefinition == null) return "";
|
||||
|
||||
@@ -134,637 +117,44 @@ public class GroovyToJavaGenerator {
|
||||
return prefix.replace('.', '/') + '/';
|
||||
}
|
||||
|
||||
private void generateClassStub(@NotNull PsiClass typeDefinition, GrPackageDefinition packageDefinition, Map<String, String> output) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
public CharSequence generateClass(@NotNull PsiClass typeDefinition) {
|
||||
try {
|
||||
writeTypeDefinition(text, typeDefinition, packageDefinition, true);
|
||||
|
||||
|
||||
final String fileName;
|
||||
if (fullConversion) {
|
||||
fileName = typeDefinition.getName() + ".java";
|
||||
}
|
||||
else {
|
||||
fileName = getPackageDirectory(packageDefinition) + typeDefinition.getName() + ".java";
|
||||
}
|
||||
output.put(fileName, text.toString());
|
||||
StringBuilder text = new StringBuilder();
|
||||
final ClassNameProvider classNameProvider =
|
||||
fullConversion ? new GeneratorClassNameProvider() : new StubClassNameProvider(myAllToCompile);
|
||||
new ClassGenerator(myProject, classNameProvider).writeTypeDefinition(text, typeDefinition, true);
|
||||
return text;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static GrTopStatement[] getTopStatementsInReadAction(final GroovyFileBase file) {
|
||||
if (file == null) return new GrTopStatement[0];
|
||||
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<GrTopStatement[]>() {
|
||||
public GrTopStatement[] compute() {
|
||||
return file.getTopStatements();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeTypeDefinition(StringBuilder text,
|
||||
@NotNull final PsiClass typeDefinition,
|
||||
@Nullable GrPackageDefinition packageDefinition,
|
||||
boolean toplevel) {
|
||||
final boolean isScript = typeDefinition instanceof GroovyScriptClass;
|
||||
|
||||
writePackageStatement(text, packageDefinition);
|
||||
|
||||
boolean isEnum = typeDefinition.isEnum();
|
||||
boolean isAnnotationType = typeDefinition.isAnnotationType();
|
||||
boolean isInterface = !isAnnotationType && typeDefinition.isInterface();
|
||||
boolean isClassDef = !isInterface && !isEnum && !isAnnotationType && !isScript;
|
||||
|
||||
GenerationUtil.writeClassModifiers(text, typeDefinition.getModifierList(), typeDefinition.isInterface(), toplevel);
|
||||
|
||||
if (isInterface) {
|
||||
text.append("interface");
|
||||
}
|
||||
else if (isEnum) {
|
||||
text.append("enum");
|
||||
}
|
||||
else if (isAnnotationType) {
|
||||
text.append("@interface");
|
||||
}
|
||||
else {
|
||||
text.append("class");
|
||||
}
|
||||
|
||||
text.append(" ").append(typeDefinition.getName());
|
||||
|
||||
appendTypeParameters(text, typeDefinition);
|
||||
|
||||
text.append(" ");
|
||||
|
||||
if (isScript) {
|
||||
text.append("extends groovy.lang.Script ");
|
||||
}
|
||||
else if (!isEnum && !isAnnotationType) {
|
||||
final PsiClassType[] extendsClassesTypes = typeDefinition.getExtendsListTypes();
|
||||
|
||||
if (extendsClassesTypes.length > 0) {
|
||||
text.append("extends ").append(getTypeText(extendsClassesTypes[0], typeDefinition, false)).append(" ");
|
||||
}
|
||||
|
||||
final Collection<PsiClassType> implementsTypes = new LinkedHashSet<PsiClassType>();
|
||||
Collections.addAll(implementsTypes, typeDefinition.getImplementsListTypes());
|
||||
/*for (PsiClass aClass : collectDelegateTypes(typeDefinition)) {
|
||||
if (aClass.isInterface()) {
|
||||
implementsTypes.add(JavaPsiFacade.getElementFactory(myProject).createType(aClass));
|
||||
} else {
|
||||
Collections.addAll(implementsTypes, aClass.getImplementsListTypes());
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!implementsTypes.isEmpty()) {
|
||||
text.append(isInterface ? "extends " : "implements ");
|
||||
text.append(StringUtil.join(implementsTypes, new Function<PsiClassType, String>() {
|
||||
@Override
|
||||
public String fun(PsiClassType psiClassType) {
|
||||
return getTypeText(psiClassType, typeDefinition, false);
|
||||
}
|
||||
}, ", "));
|
||||
text.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
text.append("{");
|
||||
|
||||
if (isEnum) {
|
||||
writeEnumConstants(text, (GrEnumTypeDefinition)typeDefinition);
|
||||
}
|
||||
|
||||
writeAllMethods(text, collectMethods(typeDefinition, isClassDef), typeDefinition);
|
||||
|
||||
if (typeDefinition instanceof GrTypeDefinition) {
|
||||
for (GrMembersDeclaration declaration : ((GrTypeDefinition)typeDefinition).getMemberDeclarations()) {
|
||||
if (declaration instanceof GrVariableDeclaration) {
|
||||
writeVariableDeclarations(text, (GrVariableDeclaration)declaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PsiClass inner : typeDefinition.getInnerClasses()) {
|
||||
writeTypeDefinition(text, inner, null, false);
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
text.append("}");
|
||||
}
|
||||
|
||||
private void writeAllMethods(StringBuilder text, Collection<PsiMethod> methods, PsiClass aClass) {
|
||||
Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
|
||||
for (PsiMethod method : methods) {
|
||||
if (!shouldBeGenerated(method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (method instanceof GrConstructor) {
|
||||
writeConstructor(text, (GrConstructor)method, aClass.isEnum(), true);
|
||||
continue;
|
||||
}
|
||||
|
||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (parameters.length > 0) {
|
||||
PsiParameter[] parametersCopy = new PsiParameter[parameters.length];
|
||||
PsiType[] parameterTypes = new PsiType[parameters.length];
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
parametersCopy[i] = parameters[i];
|
||||
parameterTypes[i] = findOutParameterType(parameters[i]);
|
||||
}
|
||||
|
||||
for (int i = parameters.length - 1; i >= 0; i--) {
|
||||
MethodSignature signature =
|
||||
MethodSignatureUtil.createMethodSignature(method.getName(), parameterTypes, method.getTypeParameters(), PsiSubstitutor.EMPTY);
|
||||
if (methodSignatures.add(signature)) {
|
||||
writeMethod(text, method, parametersCopy, true);
|
||||
}
|
||||
|
||||
PsiParameter parameter = parameters[i];
|
||||
if (!(parameter instanceof GrParameter) || !((GrParameter)parameter).isOptional()) break;
|
||||
parameterTypes = ArrayUtil.remove(parameterTypes, parameterTypes.length - 1);
|
||||
parametersCopy = ArrayUtil.remove(parametersCopy, parametersCopy.length - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
|
||||
if (methodSignatures.add(signature)) {
|
||||
writeMethod(text, method, parameters, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldBeGenerated(PsiMethod method) {
|
||||
for (PsiMethod psiMethod : method.findSuperMethods()) {
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
final PsiType type = method.getReturnType();
|
||||
final PsiType superType = psiMethod.getReturnType();
|
||||
if (type != null && superType != null && !superType.isAssignableFrom(type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Collection<PsiMethod> collectMethods(PsiClass typeDefinition, boolean classDef) {
|
||||
List<PsiMethod> methods = new ArrayList<PsiMethod>();
|
||||
ContainerUtil.addAll(methods, typeDefinition.getMethods());
|
||||
if (classDef) {
|
||||
final Collection<MethodSignature> toOverride = OverrideImplementUtil.getMethodSignaturesToOverride(typeDefinition);
|
||||
for (MethodSignature signature : toOverride) {
|
||||
if (signature instanceof MethodSignatureBackedByPsiMethod) {
|
||||
final PsiMethod method = ((MethodSignatureBackedByPsiMethod)signature).getMethod();
|
||||
final PsiClass baseClass = method.getContainingClass();
|
||||
if (isAbstractInJava(method) && baseClass != null && typeDefinition.isInheritor(baseClass, true)) {
|
||||
methods.add(mirrorMethod(typeDefinition, method, baseClass, PsiSubstitutor.EMPTY, GenerationUtil.JAVA_MODIFIERS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
|
||||
methods.add(factory.createMethodFromText("public groovy.lang.MetaClass getMetaClass() {}", null));
|
||||
methods.add(factory.createMethodFromText("public void setMetaClass(groovy.lang.MetaClass mc) {}", null));
|
||||
methods.add(factory.createMethodFromText("public Object invokeMethod(String name, Object args) {}", null));
|
||||
methods.add(factory.createMethodFromText("public Object getProperty(String propertyName) {}", null));
|
||||
methods.add(factory.createMethodFromText("public void setProperty(String propertyName, Object newValue) {}", null));
|
||||
}
|
||||
|
||||
if (typeDefinition instanceof GrTypeDefinition) {
|
||||
for (PsiMethod delegatedMethod : GrClassImplUtil.getDelegatedMethods((GrTypeDefinition)typeDefinition)) {
|
||||
methods.add(delegatedMethod);
|
||||
}
|
||||
}
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
||||
private static LightMethodBuilder mirrorMethod(PsiClass typeDefinition,
|
||||
PsiMethod method,
|
||||
PsiClass baseClass,
|
||||
PsiSubstitutor substitutor,
|
||||
String... modifierFilter) {
|
||||
final LightMethodBuilder builder = new LightMethodBuilder(method.getManager(), method.getName());
|
||||
substitutor = substitutor.putAll(TypeConversionUtil.getSuperClassSubstitutor(baseClass, typeDefinition, PsiSubstitutor.EMPTY));
|
||||
for (PsiParameter parameter : method.getParameterList().getParameters()) {
|
||||
builder.addParameter(StringUtil.notNullize(parameter.getName()), substitutor.substitute(findOutParameterType(parameter)));
|
||||
}
|
||||
builder.setReturnType(substitutor.substitute(method.getReturnType()));
|
||||
for (String modifier : modifierFilter) {
|
||||
if (method.hasModifierProperty(modifier)) {
|
||||
builder.addModifier(modifier);
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static boolean isAbstractInJava(PsiMethod method) {
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiClass psiClass = method.getContainingClass();
|
||||
return psiClass != null && GrClassSubstitutor.getSubstitutedClass(psiClass).isInterface();
|
||||
}
|
||||
|
||||
private void appendTypeParameters(StringBuilder text, PsiTypeParameterListOwner typeParameterListOwner) {
|
||||
if (typeParameterListOwner.hasTypeParameters()) {
|
||||
text.append("<");
|
||||
PsiTypeParameter[] parameters = typeParameterListOwner.getTypeParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (i > 0) text.append(", ");
|
||||
PsiTypeParameter parameter = parameters[i];
|
||||
text.append(parameter.getName());
|
||||
PsiClassType[] extendsListTypes = parameter.getExtendsListTypes();
|
||||
if (extendsListTypes.length > 0) {
|
||||
text.append(" extends ");
|
||||
for (int j = 0; j < extendsListTypes.length; j++) {
|
||||
if (j > 0) text.append(" & ");
|
||||
text.append(getTypeText(extendsListTypes[j], typeParameterListOwner, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
text.append(">");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeEnumConstants(StringBuilder text, GrEnumTypeDefinition enumDefinition) {
|
||||
text.append("\n ");
|
||||
GrEnumConstant[] enumConstants = enumDefinition.getEnumConstants();
|
||||
for (int i = 0; i < enumConstants.length; i++) {
|
||||
if (i > 0) text.append(", ");
|
||||
GrEnumConstant enumConstant = enumConstants[i];
|
||||
text.append(enumConstant.getName());
|
||||
PsiMethod constructor = enumConstant.resolveMethod();
|
||||
if (constructor != null) {
|
||||
text.append("(");
|
||||
writeStubConstructorInvocation(text, constructor, PsiSubstitutor.EMPTY);
|
||||
text.append(")");
|
||||
}
|
||||
|
||||
GrTypeDefinitionBody block = enumConstant.getAnonymousBlock();
|
||||
if (block != null) {
|
||||
text.append("{\n");
|
||||
for (PsiMethod method : block.getMethods()) {
|
||||
writeMethod(text, method, method.getParameterList().getParameters(), true);
|
||||
}
|
||||
text.append("}");
|
||||
}
|
||||
}
|
||||
text.append(";");
|
||||
}
|
||||
|
||||
private void writeStubConstructorInvocation(StringBuilder text, PsiMethod constructor, PsiSubstitutor substitutor) {
|
||||
final PsiParameter[] superParams = constructor.getParameterList().getParameters();
|
||||
for (int j = 0; j < superParams.length; j++) {
|
||||
if (j > 0) text.append(", ");
|
||||
String typeText = getTypeText(substitutor.substitute(findOutParameterType(superParams[j])), null, false);
|
||||
text.append("(").append(typeText).append(")").append(getDefaultValueText(typeText));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writePackageStatement(StringBuilder text, GrPackageDefinition packageDefinition) {
|
||||
if (packageDefinition != null) {
|
||||
text.append("package ");
|
||||
text.append(packageDefinition.getPackageName());
|
||||
text.append(";");
|
||||
text.append("\n");
|
||||
text.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeConstructor(final StringBuilder text, final GrConstructor constructor, boolean isEnum, final boolean prefix) {
|
||||
if (prefix) {
|
||||
text.append("\n");
|
||||
text.append(" ");
|
||||
}
|
||||
if (!isEnum) {
|
||||
text.append("public ");
|
||||
//writeModifiers(text, constructor.getModifierList(), JAVA_MODIFIERS);
|
||||
}
|
||||
|
||||
/************* name **********/
|
||||
//append constructor name
|
||||
text.append(constructor.getName());
|
||||
|
||||
/************* parameters **********/
|
||||
GrParameter[] parameterList = constructor.getParameters();
|
||||
|
||||
writeParameterList(text, parameterList);
|
||||
|
||||
final Set<String> throwsTypes = collectThrowsTypes(constructor, new THashSet<PsiMethod>());
|
||||
if (!throwsTypes.isEmpty()) {
|
||||
text.append("throws ").append(StringUtil.join(throwsTypes, ", ")).append(" ");
|
||||
}
|
||||
|
||||
/************* body **********/
|
||||
|
||||
text.append("{\n");
|
||||
final GrConstructorInvocation invocation = constructor.getChainingConstructorInvocation();
|
||||
if (invocation != null) {
|
||||
final GroovyResolveResult resolveResult = resolveChainingConstructor(constructor);
|
||||
if (resolveResult != null) {
|
||||
text.append(" ");
|
||||
text.append(invocation.isSuperCall() ? "super(" : "this(");
|
||||
writeStubConstructorInvocation(text, (PsiMethod) resolveResult.getElement(), resolveResult.getSubstitutor());
|
||||
text.append(");");
|
||||
}
|
||||
}
|
||||
|
||||
text.append("\n }\n");
|
||||
}
|
||||
|
||||
private Set<String> collectThrowsTypes(GrConstructor constructor, Set<PsiMethod> visited) {
|
||||
final GroovyResolveResult resolveResult = resolveChainingConstructor(constructor);
|
||||
if (resolveResult == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
|
||||
final PsiMethod chainedConstructor = (PsiMethod)resolveResult.getElement();
|
||||
assert chainedConstructor != null;
|
||||
|
||||
if (!visited.add(chainedConstructor)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final Set<String> result = CollectionFactory.newTroveSet(ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
for (PsiClassType type : chainedConstructor.getThrowsList().getReferencedTypes()) {
|
||||
result.add(getTypeText(substitutor.substitute(type), null, false));
|
||||
}
|
||||
|
||||
if (chainedConstructor instanceof GrConstructor) {
|
||||
result.addAll(collectThrowsTypes((GrConstructor)chainedConstructor, visited));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GroovyResolveResult resolveChainingConstructor(GrConstructor constructor) {
|
||||
final GrConstructorInvocation constructorInvocation = constructor.getChainingConstructorInvocation();
|
||||
if (constructorInvocation == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GroovyResolveResult resolveResult = constructorInvocation.resolveConstructorGenerics();
|
||||
if (resolveResult.getElement() != null) {
|
||||
return resolveResult;
|
||||
}
|
||||
|
||||
final GroovyResolveResult[] results = constructorInvocation.multiResolveConstructor();
|
||||
if (results.length > 0) {
|
||||
int i = 0;
|
||||
while (results.length > i+1) {
|
||||
final PsiMethod candidate = (PsiMethod)results[i].getElement();
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(constructor.getProject()).getResolveHelper();
|
||||
if (candidate != null && candidate != constructor && resolveHelper.isAccessible(candidate, constructorInvocation, null)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return results[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getDefaultValueText(String typeCanonicalText) {
|
||||
public static String getDefaultValueText(String typeCanonicalText) {
|
||||
final String result = typesToInitialValues.get(typeCanonicalText);
|
||||
if (result == null) return "null";
|
||||
return result;
|
||||
}
|
||||
|
||||
private void writeVariableDeclarations(StringBuilder text, GrVariableDeclaration variableDeclaration) {
|
||||
GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
|
||||
final String type = typeElement == null ? CommonClassNames.JAVA_LANG_OBJECT : getTypeText(typeElement.getType(), typeElement, false);
|
||||
final String initializer = getDefaultValueText(type);
|
||||
|
||||
final GrModifierList modifierList = variableDeclaration.getModifierList();
|
||||
final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(variableDeclaration.getProject()).getNameHelper();
|
||||
for (final GrVariable variable : variableDeclaration.getVariables()) {
|
||||
String name = variable.getName();
|
||||
if (!nameHelper.isIdentifier(name)) {
|
||||
continue; //does not have a java image
|
||||
}
|
||||
|
||||
text.append("\n ");
|
||||
GenerationUtil.writeModifiers(text, modifierList, GenerationUtil.JAVA_MODIFIERS);
|
||||
|
||||
//type
|
||||
text.append(type).append(" ").append(name).append(" = ").append(initializer);
|
||||
text.append(";\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static String generateMethodStub(@NotNull PsiMethod method) {
|
||||
if (!(method instanceof GroovyPsiElement)) {
|
||||
return method.getText();
|
||||
}
|
||||
|
||||
final GroovyToJavaGenerator generator = new GroovyToJavaGenerator(method.getProject(), Collections.<VirtualFile>emptyList(), false);
|
||||
final ClassGenerator generator =
|
||||
new ClassGenerator(method.getProject(), new StubClassNameProvider(Collections.<VirtualFile>emptySet()));
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
if (method instanceof GrConstructor) {
|
||||
generator.writeConstructor(buffer, (GrConstructor)method, false, false);
|
||||
generator.writeConstructor(buffer, (GrConstructor)method, false);
|
||||
}
|
||||
else {
|
||||
generator.writeMethod(buffer, method, method.getParameterList().getParameters(), false);
|
||||
generator.writeMethod(buffer, method, method.getParameterList().getParameters());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private void writeMethod(StringBuilder text, PsiMethod method, final PsiParameter[] parameters, final boolean prefix) {
|
||||
if (method == null) return;
|
||||
String name = method.getName();
|
||||
if (!JavaPsiFacade.getInstance(method.getProject()).getNameHelper().isIdentifier(name))
|
||||
return; //does not have a java image
|
||||
|
||||
boolean isAbstract = isAbstractInJava(method);
|
||||
|
||||
PsiModifierList modifierList = method.getModifierList();
|
||||
|
||||
if (prefix) {
|
||||
text.append("\n");
|
||||
text.append(" ");
|
||||
}
|
||||
GenerationUtil.writeModifiers(text, modifierList, GenerationUtil.JAVA_MODIFIERS);
|
||||
if (method.hasTypeParameters()) {
|
||||
appendTypeParameters(text, method);
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
//append return type
|
||||
PsiType retType = findOutReturnTypeOfMethod(method);
|
||||
|
||||
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
final List<MethodSignatureBackedByPsiMethod> superSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
|
||||
for (MethodSignatureBackedByPsiMethod superSignature : superSignatures) {
|
||||
final PsiType superType = superSignature.getSubstitutor().substitute(superSignature.getMethod().getReturnType());
|
||||
if (superType != null && !superType.isAssignableFrom(retType) && !(PsiUtil.resolveClassInType(superType) instanceof PsiTypeParameter)) {
|
||||
retType = superType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text.append(getTypeText(retType, method, false));
|
||||
text.append(" ");
|
||||
|
||||
text.append(name);
|
||||
|
||||
writeParameterList(text, parameters);
|
||||
|
||||
writeThrowsList(text, method);
|
||||
|
||||
if (!isAbstract) {
|
||||
/************* body **********/
|
||||
generateMethodBody(text, method, retType);
|
||||
}
|
||||
else {
|
||||
text.append(";");
|
||||
}
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
private void generateMethodBody(StringBuilder text, PsiMethod method, PsiType retType) {
|
||||
if (!fullConversion) {
|
||||
text.append("{\n return ");
|
||||
text.append(getDefaultValueText(getTypeText(retType, method, false)));
|
||||
text.append(";\n }");
|
||||
return;
|
||||
}
|
||||
//todo
|
||||
if (method instanceof GrMethod) {
|
||||
final CodeBlockGenerator blockGenerator = new CodeBlockGenerator(new StringBuilder(), myProject);
|
||||
//blockGenerator.generate();
|
||||
//todo
|
||||
}
|
||||
}
|
||||
|
||||
private void writeThrowsList(StringBuilder text, PsiMethod method) {
|
||||
final PsiReferenceList throwsList = method.getThrowsList();
|
||||
final PsiClassType[] exceptions = throwsList.getReferencedTypes();
|
||||
if (exceptions.length > 0) {
|
||||
text.append("throws ");
|
||||
for (int i = 0; i < exceptions.length; i++) {
|
||||
PsiClassType exception = exceptions[i];
|
||||
if (i != 0) {
|
||||
text.append(",");
|
||||
}
|
||||
text.append(getTypeText(exception, method, false));
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
//todo search for all thrown exceptions from this file methods
|
||||
}
|
||||
}
|
||||
|
||||
private PsiType findOutReturnTypeOfMethod(PsiMethod method) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (returnType != null) return returnType;
|
||||
|
||||
if (!fullConversion) return TypesUtil.getJavaLangObject(method);
|
||||
|
||||
final PsiType smartReturnType = org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.getSmartReturnType(method);
|
||||
if (smartReturnType != null) return smartReturnType;
|
||||
|
||||
//todo make smarter. search for usages and infer type from them
|
||||
return TypesUtil.getJavaLangObject(method);
|
||||
//final Collection<PsiReference> collection = MethodReferencesSearch.search(method).findAll();
|
||||
}
|
||||
|
||||
private void writeParameterList(StringBuilder text, PsiParameter[] parameters) {
|
||||
text.append("(");
|
||||
|
||||
//writes myParameters
|
||||
int i = 0;
|
||||
while (i < parameters.length) {
|
||||
PsiParameter parameter = parameters[i];
|
||||
if (parameter == null) continue;
|
||||
|
||||
if (i > 0) text.append(", "); //append ','
|
||||
|
||||
text.append(getTypeText(findOutParameterType(parameter), parameter, i == parameters.length - 1));
|
||||
text.append(" ");
|
||||
text.append(parameter.getName());
|
||||
|
||||
i++;
|
||||
}
|
||||
text.append(")");
|
||||
text.append(" ");
|
||||
}
|
||||
|
||||
private static PsiType findOutParameterType(PsiParameter parameter) {
|
||||
return parameter.getType(); //todo make smarter
|
||||
}
|
||||
|
||||
private String getTypeText(@Nullable PsiType type, @Nullable final PsiElement context, boolean allowVarargs) {
|
||||
if (type instanceof PsiArrayType) {
|
||||
String componentText = getTypeText(((PsiArrayType)type).getComponentType(), context, false);
|
||||
if (allowVarargs && type instanceof PsiEllipsisType) {
|
||||
return componentText + "...";
|
||||
}
|
||||
return componentText + "[]";
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
return CommonClassNames.JAVA_LANG_OBJECT;
|
||||
}
|
||||
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClass raw = ((PsiClassType)type).resolve();
|
||||
if (raw != null) {
|
||||
final String qname = getClassQualifiedName(raw, context);
|
||||
if (qname != null) {
|
||||
final PsiType[] parameters = ((PsiClassType)type).getParameters();
|
||||
if (parameters.length > 0) {
|
||||
return qname + "<" + StringUtil.join(parameters, new Function<PsiType, String>() {
|
||||
@Override
|
||||
public String fun(PsiType type) {
|
||||
return getTypeText(type, context, false);
|
||||
}
|
||||
}, ", ") + ">";
|
||||
}
|
||||
return qname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String canonicalText = type.getCanonicalText();
|
||||
return canonicalText != null ? canonicalText : type.getPresentableText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getClassQualifiedName(PsiClass psiClass, @Nullable PsiElement context) {
|
||||
if (context != null) {
|
||||
psiClass = findAccessibleSuperClass(context, psiClass);
|
||||
}
|
||||
if (psiClass == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (psiClass instanceof GrTypeDefinition) {
|
||||
if (!myAllToCompile.contains(psiClass.getContainingFile().getVirtualFile())) {
|
||||
final PsiClass container = psiClass.getContainingClass();
|
||||
if (container != null) {
|
||||
return getClassQualifiedName(container, null) + "$" + psiClass.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return psiClass.getQualifiedName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiClass findAccessibleSuperClass(@NotNull PsiElement context, @NotNull PsiClass initialClass) {
|
||||
PsiClass curClass = initialClass;
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper();
|
||||
while (curClass != null && !resolveHelper.isAccessible(curClass, context, null)) {
|
||||
curClass = curClass.getSuperClass();
|
||||
}
|
||||
return curClass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class StubClassNameProvider implements ClassNameProvider {
|
||||
private Set<VirtualFile> myAllToCompile;
|
||||
|
||||
public StubClassNameProvider(Set<VirtualFile> allToCompile) {
|
||||
myAllToCompile = allToCompile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQualifiedClassName(@Nullable PsiClass psiClass, @Nullable PsiElement context) {
|
||||
if (context != null && psiClass != null) {
|
||||
psiClass = GenerationUtil.findAccessibleSuperClass(context, psiClass);
|
||||
}
|
||||
if (psiClass == null) {
|
||||
return CommonClassNames.JAVA_LANG_OBJECT;
|
||||
}
|
||||
|
||||
if (psiClass instanceof GrTypeDefinition) {
|
||||
if (!myAllToCompile.contains(psiClass.getContainingFile().getVirtualFile())) {
|
||||
final PsiClass container = psiClass.getContainingClass();
|
||||
if (container != null) {
|
||||
return getQualifiedClassName(container, null) + "$" + psiClass.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
final String name = psiClass.getQualifiedName();
|
||||
if (name!=null) return name;
|
||||
return psiClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forStubs() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.refactoring.convertToJava.GroovyToJavaGenerator;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -99,21 +99,21 @@ public class GeneratorTest extends LightGroovyTestCase {
|
||||
final String relTestPath = getTestName(true) + ".test";
|
||||
final List<String> data = TestUtils.readInput(getTestDataPath() + "/" + relTestPath);
|
||||
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final String testName = StringUtil.trimEnd(relTestPath, ".test");
|
||||
PsiFile psiFile = TestUtils.createPseudoPhysicalFile(getProject(), testName + ".groovy", data.get(0));
|
||||
final Map<String,String> map =
|
||||
new GroovyToJavaGenerator(getProject(), Arrays.asList(psiFile.getViewProvider().getVirtualFile()), false)
|
||||
final Map<String, CharSequence> map =
|
||||
new GroovyToJavaGenerator(getProject(), Collections.singleton(psiFile.getViewProvider().getVirtualFile()), false)
|
||||
.generateStubs((GroovyFile)psiFile);
|
||||
|
||||
for (String stubText : map.values()) {
|
||||
buffer.append(stubText);
|
||||
buffer.append("\n");
|
||||
buffer.append("---");
|
||||
buffer.append("\n");
|
||||
for (CharSequence stubText : map.values()) {
|
||||
builder.append(stubText);
|
||||
builder.append("\n");
|
||||
builder.append("---");
|
||||
builder.append("\n");
|
||||
}
|
||||
|
||||
assertEquals(data.get(1).trim(), buffer.toString().trim());
|
||||
assertEquals(data.get(1).trim(), builder.toString().trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,16 +7,15 @@ enum E {
|
||||
}
|
||||
-----
|
||||
public enum E {
|
||||
A((int)0){
|
||||
|
||||
public java.lang.Object foo() {
|
||||
return null;
|
||||
}
|
||||
A((int)0){
|
||||
public java.lang.Object foo() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
E(int i) {
|
||||
E(int i) {
|
||||
|
||||
}
|
||||
}
|
||||
public abstract java.lang.Object foo() ;
|
||||
|
||||
public abstract java.lang.Object foo() ;
|
||||
}
|
||||
---
|
||||
+35
-36
@@ -7,52 +7,51 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public int[] foo() {
|
||||
return null;
|
||||
}
|
||||
public int[] foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object[] getObj() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object[] getObj() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int[] getIntegers() {
|
||||
return null;
|
||||
}
|
||||
public int[] getIntegers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setIntegers(int[] integers) {
|
||||
return ;
|
||||
}
|
||||
public void setIntegers(int[] integers) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.String[] getStrings() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.String[] getStrings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setStrings(java.lang.String[] strings) {
|
||||
return ;
|
||||
}
|
||||
public void setStrings(java.lang.String[] strings) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private int[] integers = null;
|
||||
|
||||
private java.lang.String[] strings = null;
|
||||
private int[] integers = null;
|
||||
private java.lang.String[] strings = null;
|
||||
}
|
||||
---
|
||||
@@ -4,5 +4,6 @@ import java.lang.annotation.*
|
||||
|
||||
}
|
||||
-----
|
||||
public @interface III {}
|
||||
public @interface III {
|
||||
}
|
||||
---
|
||||
+27
-28
@@ -9,32 +9,31 @@ class Foo extends foo.SuperClass {
|
||||
|
||||
-----
|
||||
public class Foo extends foo.SuperClass implements groovy.lang.GroovyObject {
|
||||
public Foo(Foo p) throws java.io.IOException {
|
||||
this((java.lang.String)null);
|
||||
}
|
||||
|
||||
public Foo(java.lang.String s) throws java.io.IOException {
|
||||
super((java.lang.String)null);
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public Foo(Foo p) throws java.io.IOException {
|
||||
this((java.lang.String)null);
|
||||
}
|
||||
---
|
||||
public Foo(java.lang.String s) throws java.io.IOException {
|
||||
super((java.lang.String)null);
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
---
|
||||
@@ -3,6 +3,6 @@ interface Foo {
|
||||
}
|
||||
-----
|
||||
public interface Foo {
|
||||
public static final java.lang.Object bar = null;
|
||||
public static final java.lang.Object bar = null;
|
||||
}
|
||||
---
|
||||
+58
-58
@@ -11,72 +11,72 @@ class DelegateBarImpl {
|
||||
}
|
||||
-----
|
||||
public interface DelegateFoo {
|
||||
public java.lang.Object foo() ;
|
||||
public java.lang.Object foo() ;
|
||||
|
||||
}
|
||||
---
|
||||
public class Doo extends groovy.lang.GroovyObjectSupport implements java.io.Serializable, groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class DelegateBarImpl extends groovy.lang.GroovyObjectSupport implements DelegateFoo, java.lang.Runnable, java.io.Serializable, groovy.lang.GroovyObject {
|
||||
public DelegateFoo getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFoo(DelegateFoo foo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private DelegateFoo foo = null;
|
||||
|
||||
private java.lang.Runnable zoo = null;
|
||||
|
||||
private Doo doo = null;
|
||||
public DelegateFoo getFoo() {
|
||||
return null;
|
||||
}
|
||||
---
|
||||
|
||||
public void setFoo(DelegateFoo foo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private DelegateFoo foo = null;
|
||||
private java.lang.Runnable zoo = null;
|
||||
private Doo doo = null;
|
||||
}
|
||||
---
|
||||
@@ -7,38 +7,39 @@ class ConfigNode {
|
||||
}
|
||||
-----
|
||||
public interface Foo<K, V> {
|
||||
public V get(K k) ;
|
||||
public V get(K k) ;
|
||||
|
||||
}
|
||||
---
|
||||
public class ConfigNode extends groovy.lang.GroovyObjectSupport implements Foo<java.lang.String, java.lang.Object>, groovy.lang.GroovyObject {
|
||||
public final Foo<java.lang.String, java.lang.Object> getDelegate() {
|
||||
return null;
|
||||
}
|
||||
public final Foo<java.lang.String, java.lang.Object> getDelegate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object get(java.lang.String k) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object get(java.lang.String k) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private final Foo<java.lang.String, java.lang.Object> delegate = null;
|
||||
private final Foo<java.lang.String, java.lang.Object> delegate = null;
|
||||
}
|
||||
---
|
||||
+32
-30
@@ -4,46 +4,48 @@ class a extends b {
|
||||
}
|
||||
-----
|
||||
public class b extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class a extends b implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -2,24 +2,25 @@ class a extends GroovyObjectSupport implements GroovyObject {
|
||||
}
|
||||
-----
|
||||
public class a extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -4,16 +4,17 @@ def getFoo () {
|
||||
}
|
||||
-----
|
||||
public class getterAlreadyDefined extends groovy.lang.Script {
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getFoo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
---
|
||||
+35
-35
@@ -7,54 +7,54 @@ class B extends A {
|
||||
}
|
||||
-----
|
||||
public class A extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public static final java.lang.Object getTEST() {
|
||||
return null;
|
||||
}
|
||||
public static final java.lang.Object getTEST() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private static final java.lang.Object TEST = null;
|
||||
private static final java.lang.Object TEST = null;
|
||||
}
|
||||
---
|
||||
public class B extends A implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private static final java.lang.Object TEST = null;
|
||||
private static final java.lang.Object TEST = null;
|
||||
}
|
||||
---
|
||||
+36
-34
@@ -9,52 +9,54 @@ class B extends A {
|
||||
}
|
||||
-----
|
||||
public abstract class A extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public abstract java.lang.Object myMethod() ;
|
||||
public abstract java.lang.Object myMethod() ;
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class B extends A implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object myMethod() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object myMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+25
-25
@@ -3,38 +3,38 @@ class MyClass {
|
||||
}
|
||||
-----
|
||||
public class MyClass extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public boolean getEnabled() {
|
||||
return false;
|
||||
}
|
||||
public boolean getEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
return ;
|
||||
}
|
||||
public void setEnabled(boolean enabled) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private boolean enabled = false;
|
||||
private boolean enabled = false;
|
||||
}
|
||||
---
|
||||
+18
-18
@@ -5,28 +5,28 @@ class PerformanceLine extends HashMap {
|
||||
}
|
||||
-----
|
||||
public class PerformanceLine extends java.util.HashMap implements groovy.lang.GroovyObject {
|
||||
public PerformanceLine(java.lang.String... data) {
|
||||
super((java.util.Map)null);
|
||||
}
|
||||
public PerformanceLine(java.lang.String... data) {
|
||||
super((java.util.Map)null);
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+20
-17
@@ -5,29 +5,32 @@ interface Foo extends IBar {
|
||||
class Test1 implements Foo {
|
||||
}
|
||||
-----
|
||||
public interface IBar extends groovy.lang.GroovyObject {}
|
||||
public interface IBar extends groovy.lang.GroovyObject {
|
||||
}
|
||||
---
|
||||
public interface Foo extends IBar {}
|
||||
public interface Foo extends IBar {
|
||||
}
|
||||
---
|
||||
public class Test1 extends groovy.lang.GroovyObjectSupport implements Foo, groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+20
-21
@@ -8,32 +8,31 @@ class MyTestClass {
|
||||
}
|
||||
-----
|
||||
public class MyTestClass extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public MyTestClass(java.lang.String s) {
|
||||
public MyTestClass(java.lang.String s) {
|
||||
|
||||
}
|
||||
}
|
||||
public MyTestClass() {
|
||||
this((java.lang.String)null);
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public MyTestClass() {
|
||||
this((java.lang.String)null);
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+20
-21
@@ -9,32 +9,31 @@ class MyClass {
|
||||
}
|
||||
-----
|
||||
public class MyClass extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public MyClass(int i) {
|
||||
this((java.lang.Object)null);
|
||||
}
|
||||
public MyClass(int i) {
|
||||
this((java.lang.Object)null);
|
||||
}
|
||||
public MyClass(java.lang.Object o) {
|
||||
|
||||
public MyClass(java.lang.Object o) {
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+38
-36
@@ -11,54 +11,56 @@ class FailingA {
|
||||
}
|
||||
-----
|
||||
public class FailingA extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
protected void act() {
|
||||
return ;
|
||||
}
|
||||
protected void act() {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public final class FailingB extends FailingA implements groovy.lang.GroovyObject {
|
||||
public void act() {
|
||||
return ;
|
||||
}
|
||||
public void act() {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+19
-18
@@ -3,28 +3,29 @@ class A implements Comparable {
|
||||
}
|
||||
-----
|
||||
public class A extends groovy.lang.GroovyObjectSupport implements java.lang.Comparable, groovy.lang.GroovyObject {
|
||||
public int compare(A anotherA) {
|
||||
return 0;
|
||||
}
|
||||
public int compare(A anotherA) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+39
-41
@@ -11,62 +11,60 @@ class ExtensionLoader extends Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Foo(java.lang.Void v, Foo p) {
|
||||
public Foo(java.lang.Void v, Foo p) {
|
||||
|
||||
}
|
||||
}
|
||||
public Foo(Foo p) {
|
||||
|
||||
public Foo(Foo p) {
|
||||
}
|
||||
public Foo() {
|
||||
|
||||
}
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Foo() {
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class ExtensionLoader extends Foo implements groovy.lang.GroovyObject {
|
||||
public ExtensionLoader(java.lang.Object parent) {
|
||||
super((Foo)null);
|
||||
}
|
||||
public ExtensionLoader(java.lang.Object parent) {
|
||||
super((Foo)null);
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+22
-22
@@ -4,34 +4,34 @@ class Foo {
|
||||
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object getProp() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProp() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProp(java.lang.Object prop) {
|
||||
return ;
|
||||
}
|
||||
public void setProp(java.lang.Object prop) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private java.lang.Object prop = null;
|
||||
private java.lang.Object prop = null;
|
||||
}
|
||||
---
|
||||
+25
-24
@@ -8,36 +8,37 @@ public T next() { throw new UnsupportedOperationException("This method is not av
|
||||
}
|
||||
-----
|
||||
public class BugSample<T> extends groovy.lang.GroovyObjectSupport implements java.util.Iterator<T>, groovy.lang.GroovyObject {
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
return ;
|
||||
}
|
||||
public void remove() {
|
||||
return ;
|
||||
}
|
||||
|
||||
public T next() {
|
||||
return null;
|
||||
}
|
||||
public T next() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -3,28 +3,29 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public <T extends java.lang.String> java.lang.Object f() {
|
||||
return null;
|
||||
}
|
||||
public <T extends java.lang.String> java.lang.Object f() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -3,40 +3,41 @@ class Test {
|
||||
}
|
||||
-----
|
||||
public class Test extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i, java.lang.Object j, java.lang.Object k) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i, java.lang.Object j, java.lang.Object k) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i, java.lang.Object j) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i, java.lang.Object j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo(java.lang.Object h, java.lang.Object i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object foo(java.lang.Object h) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo(java.lang.Object h) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -7,56 +7,57 @@ class Derived extends Base {
|
||||
}
|
||||
-----
|
||||
public class Base extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public final int getP() {
|
||||
return 0;
|
||||
}
|
||||
public final int getP() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class Derived extends Base implements groovy.lang.GroovyObject {
|
||||
public void setP(int p) {
|
||||
return ;
|
||||
}
|
||||
public void setP(int p) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private int p = 0;
|
||||
private int p = 0;
|
||||
}
|
||||
---
|
||||
+16
-15
@@ -6,24 +6,25 @@ class D {
|
||||
package a.b;
|
||||
|
||||
public class D extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -19,28 +19,29 @@ class Impl implements GwtActionService {
|
||||
|
||||
-----
|
||||
public class Impl extends groovy.lang.GroovyObjectSupport implements GwtActionService, groovy.lang.GroovyObject {
|
||||
public java.lang.CharSequence execute(java.util.List action) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.CharSequence execute(java.util.List action) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+21
-19
@@ -8,32 +8,34 @@ class Cl implements Callable<String> {
|
||||
|
||||
-----
|
||||
public interface Callable<V> {
|
||||
public V call() throws java.lang.Exception ;
|
||||
public V call() throws java.lang.Exception ;
|
||||
|
||||
}
|
||||
---
|
||||
public class Cl extends groovy.lang.GroovyObjectSupport implements Callable<java.lang.String>, groovy.lang.GroovyObject {
|
||||
public java.lang.String call() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.String call() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -1,12 +1,13 @@
|
||||
println "bugaga"
|
||||
-----
|
||||
public class script extends groovy.lang.Script {
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
---
|
||||
+16
-15
@@ -3,24 +3,25 @@ class F {
|
||||
}
|
||||
-----
|
||||
public class F extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -4,34 +4,34 @@ class D {
|
||||
}
|
||||
-----
|
||||
public class D extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public void setDDD(java.lang.Object ddd) {
|
||||
return ;
|
||||
}
|
||||
public void setDDD(java.lang.Object ddd) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object getDDD() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getDDD() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private java.lang.Object DDD = null;
|
||||
private java.lang.Object DDD = null;
|
||||
}
|
||||
---
|
||||
@@ -3,28 +3,28 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Foo() {
|
||||
public Foo() {
|
||||
|
||||
}
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -15,56 +15,58 @@ class StringMethodName {
|
||||
}
|
||||
-----
|
||||
public class StringMethodName extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object foo0() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object foo1() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo1() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Integer foo2() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Integer foo2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int foo3() {
|
||||
return 0;
|
||||
}
|
||||
public int foo3() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public java.lang.Integer foo4(java.lang.Object x) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Integer foo4(java.lang.Object x) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getFoo5() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getFoo5() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean fooFalse() {
|
||||
return false;
|
||||
}
|
||||
private boolean fooFalse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public java.lang.Object fooDef() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object fooDef() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -7,56 +7,57 @@ class Sub extends Super {
|
||||
|
||||
-----
|
||||
public class Super extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.String getFoo() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.String getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class Sub extends Super implements groovy.lang.GroovyObject {
|
||||
public void setFoo(java.lang.Object foo) {
|
||||
return ;
|
||||
}
|
||||
public void setFoo(java.lang.Object foo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private java.lang.Object foo = null;
|
||||
private java.lang.Object foo = null;
|
||||
}
|
||||
---
|
||||
@@ -9,54 +9,54 @@ class Derived extends Base {
|
||||
}
|
||||
-----
|
||||
public class Base extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Base(java.lang.String s, int i) {
|
||||
public Base(java.lang.String s, int i) {
|
||||
|
||||
}
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class Derived extends Base implements groovy.lang.GroovyObject {
|
||||
public Derived() {
|
||||
super((java.lang.String)null, (int)0);
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public Derived() {
|
||||
super((java.lang.String)null, (int)0);
|
||||
}
|
||||
---
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
---
|
||||
@@ -9,54 +9,54 @@ class Derived extends Base {
|
||||
}
|
||||
-----
|
||||
public class Base extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Base(java.lang.String s, int i) {
|
||||
public Base(java.lang.String s, int i) {
|
||||
|
||||
}
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class Derived extends Base implements groovy.lang.GroovyObject {
|
||||
public Derived() throws java.lang.Exception {
|
||||
super((java.lang.String)null, (int)0);
|
||||
}
|
||||
public Derived() throws java.lang.Exception {
|
||||
super((java.lang.String)null, (int)0);
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -3,34 +3,34 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object getBar() {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBar(java.lang.Object bar) {
|
||||
return ;
|
||||
}
|
||||
public void setBar(java.lang.Object bar) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
private java.lang.Object bar = null;
|
||||
private java.lang.Object bar = null;
|
||||
}
|
||||
---
|
||||
@@ -3,28 +3,29 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public java.lang.Object foo() throws java.io.IOException {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object foo() throws java.io.IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+16
-15
@@ -2,24 +2,25 @@ class s {
|
||||
}
|
||||
-----
|
||||
public class s extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+23
-21
@@ -4,34 +4,36 @@ class s {
|
||||
println "foo"
|
||||
-----
|
||||
public class toGenerate1 extends groovy.lang.Script {
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
public static void main(java.lang.String[] args) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class s extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+22
-21
@@ -4,32 +4,33 @@ class Foo {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public void foo(java.lang.String... foo) {
|
||||
return ;
|
||||
}
|
||||
public void foo(java.lang.String... foo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void foo(java.lang.String[] foo, java.lang.Object bar) {
|
||||
return ;
|
||||
}
|
||||
public void foo(java.lang.String[] foo, java.lang.Object bar) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
+38
-38
@@ -10,58 +10,58 @@ class Derived {
|
||||
}
|
||||
-----
|
||||
public class Foo extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Foo(java.lang.String... s) {
|
||||
public Foo(java.lang.String... s) {
|
||||
|
||||
}
|
||||
}
|
||||
public java.lang.Object foo(java.lang.String... s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object foo(java.lang.String... s) {
|
||||
return null;
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
public class Derived extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject {
|
||||
public Derived(java.lang.String... s) {
|
||||
super();
|
||||
}
|
||||
public Derived(java.lang.String... s) {
|
||||
super();
|
||||
}
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public groovy.lang.MetaClass getMetaClass() {
|
||||
return null;
|
||||
}
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setMetaClass(groovy.lang.MetaClass mc) {
|
||||
return ;
|
||||
}
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) {
|
||||
return null;
|
||||
}
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.lang.Object getProperty(java.lang.String propertyName) {
|
||||
return null;
|
||||
}
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
|
||||
public void setProperty(java.lang.String propertyName, java.lang.Object newValue) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
---
|
||||
@@ -197,6 +197,7 @@
|
||||
<action id="GenerateAntBuild" class="com.intellij.compiler.actions.GenerateAntBuildAction"/>
|
||||
<separator/>
|
||||
<action id="BuildArtifact" class="com.intellij.compiler.actions.BuildArtifactAction"/>
|
||||
<action id="CleanArtifact" class="com.intellij.compiler.actions.CleanArtifactAction"/>
|
||||
|
||||
<add-to-group group-id="MainMenu" anchor="before" relative-to-action="RunMenu"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user