mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+1
@@ -565,6 +565,7 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnnecessaryBoxing" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnnecessaryEnumModifier" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="UnnecessaryFullyQualifiedName" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<scope name="IDEA Test Sources" level="WARNING" enabled="false">
|
||||
<option name="m_ignoreJavadoc" value="false" />
|
||||
|
||||
@@ -767,6 +767,7 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnnecessaryBoxing" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnnecessaryEnumModifier" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="UnnecessaryFullyQualifiedName" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<scope name="IDEA Test Sources" level="WARNING" enabled="false">
|
||||
<option name="m_ignoreJavadoc" value="false" />
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class BreakpointChooser {
|
||||
private Project myProject;
|
||||
|
||||
private DetailView myDetailView;
|
||||
|
||||
private ActionToolbar myActionToolbar;
|
||||
private BreakpointItem myBreakpointItem;
|
||||
|
||||
private Delegate myDelegate;
|
||||
private final ComboBoxAction myComboBoxAction;
|
||||
private BreakpointMasterDetailPopupBuilder myPopupBuilder;
|
||||
|
||||
private Object mySelectedBreakpoint;
|
||||
|
||||
public void setDetailView(DetailView detailView) {
|
||||
myDetailView = detailView;
|
||||
}
|
||||
|
||||
public Object getSelectedBreakpoint() {
|
||||
return mySelectedBreakpoint;
|
||||
}
|
||||
|
||||
public BreakpointItem getBreakpointItem() {
|
||||
return myBreakpointItem;
|
||||
}
|
||||
|
||||
public void setSelectedBreakpoint(Object selectedBreakpoint) {
|
||||
mySelectedBreakpoint = selectedBreakpoint;
|
||||
myBreakpointItem = selectedBreakpoint != null ? new JavaBreakpointItem(null, (Breakpoint)selectedBreakpoint) : null;
|
||||
updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem);
|
||||
myActionToolbar.getComponent().repaint();
|
||||
}
|
||||
|
||||
private void pop(DetailView.PreviewEditorState pushed) {
|
||||
if (pushed.getFile() != null) {
|
||||
myDetailView
|
||||
.navigateInPreviewEditor(
|
||||
new DetailView.PreviewEditorState(pushed.getFile(), pushed.getNavigate(), pushed.getAttributes()));
|
||||
}
|
||||
else {
|
||||
myDetailView.clearEditor();
|
||||
}
|
||||
}
|
||||
public interface Delegate {
|
||||
void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup);
|
||||
}
|
||||
|
||||
public BreakpointChooser(Project project, Delegate delegate) {
|
||||
myProject = project;
|
||||
myDelegate = delegate;
|
||||
|
||||
myPopupBuilder = new BreakpointMasterDetailPopupBuilder(myProject);
|
||||
myPopupBuilder.setPlainView(true);
|
||||
|
||||
myComboBoxAction = new ComboBoxAction() {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
updatePresentation(presentation, BreakpointChooser.this.myBreakpointItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboBoxButton createComboBoxButton(final Presentation presentation) {
|
||||
return new ComboBoxButton(presentation) {
|
||||
@Override
|
||||
protected JBPopup createPopup(final Runnable onDispose) {
|
||||
final DetailView.PreviewEditorState pushed = myDetailView.getEditorState();
|
||||
myPopupBuilder.setIsViewer(true);
|
||||
myPopupBuilder.setAddDetailViewToEast(false);
|
||||
myPopupBuilder.setDetailView(new MyDetailView(pushed));
|
||||
myPopupBuilder.setCallback(new BreakpointMasterDetailPopupBuilder.BreakpointChosenCallback() {
|
||||
@Override
|
||||
public void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup) {
|
||||
popup.cancel();
|
||||
myBreakpointItem = breakpointItem;
|
||||
mySelectedBreakpoint = breakpointItem.getBreakpoint();
|
||||
updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem);
|
||||
updatePresentation(presentation, myBreakpointItem);
|
||||
|
||||
if (myDelegate != null) {
|
||||
myDelegate.breakpointChosen(project, breakpointItem, popup);
|
||||
}
|
||||
}
|
||||
});
|
||||
myPopupBuilder.setIsViewer(true);
|
||||
JBPopup popup = myPopupBuilder.createPopup();
|
||||
popup.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
public void beforeShown(LightweightWindowEvent event) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
onDispose.run();
|
||||
pop(pushed);
|
||||
}
|
||||
});
|
||||
return popup;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
|
||||
assert false : "should not be here";
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
myActionToolbar = ActionManager.getInstance().createActionToolbar("asdad", new DefaultActionGroup(myComboBoxAction), true);
|
||||
|
||||
}
|
||||
|
||||
public void setBreakpointItems(Collection<BreakpointItem> items) {
|
||||
myPopupBuilder.setBreakpointItems(items);
|
||||
}
|
||||
|
||||
private void updatePresentation(Presentation presentation, BreakpointItem breakpointItem) {
|
||||
if (breakpointItem != null) {
|
||||
presentation.setIcon(breakpointItem.getIcon());
|
||||
presentation.setText(breakpointItem.getDisplayText());
|
||||
}
|
||||
else {
|
||||
presentation.setText(DebuggerBundle.message("value.none"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myActionToolbar.getComponent();
|
||||
}
|
||||
|
||||
private class MyDetailView implements DetailView {
|
||||
|
||||
private final PreviewEditorState myPushed;
|
||||
|
||||
public MyDetailView(PreviewEditorState pushed) {
|
||||
myPushed = pushed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor getEditor() {
|
||||
return myDetailView.getEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateInPreviewEditor(PreviewEditorState editorState) {
|
||||
if (myDetailView != null) {
|
||||
myDetailView.navigateInPreviewEditor(editorState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getDetailPanel() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDetailPanel(@Nullable JPanel panel) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearEditor() {
|
||||
pop(myPushed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviewEditorState getEditorState() {
|
||||
return myDetailView.getEditorState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getUserData(@NotNull Key<T> key) {
|
||||
return myDetailView.getUserData(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
|
||||
myDetailView.putUserData(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+114
-129
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.InstanceFilter;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
@@ -30,12 +29,12 @@ import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.CompletionEditor;
|
||||
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
|
||||
import com.intellij.debugger.ui.DebuggerStatementEditor;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.ide.util.ClassFilter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
@@ -44,7 +43,10 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.ui.MultiLineTooltipUI;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -58,6 +60,16 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
private final BreakpointChooser myMasterBreakpointChooser;
|
||||
|
||||
public void setDetailView(DetailView detailView) {
|
||||
myDetailView = detailView;
|
||||
myMasterBreakpointChooser.setDetailView(detailView);
|
||||
}
|
||||
|
||||
private DetailView myDetailView;
|
||||
|
||||
protected final Project myProject;
|
||||
private final Key<? extends Breakpoint> myBreakpointCategory;
|
||||
private boolean myCompact;
|
||||
@@ -104,7 +116,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
ButtonGroup mySuspendPolicyGroup;
|
||||
@NonNls public static final String CONTROL_LOG_MESSAGE = "logMessage";
|
||||
private BreakpointComboboxHandler myBreakpointComboboxHandler;
|
||||
private static final int MAX_COMBO_WIDTH = 300;
|
||||
private final FixedSizeButton myConditionMagnifierButton;
|
||||
private boolean myMoreOptionsVisible = true;
|
||||
@@ -139,6 +150,10 @@ public abstract class BreakpointPropertiesPanel {
|
||||
};
|
||||
}
|
||||
|
||||
public DetailView getDetailView() {
|
||||
return myDetailView;
|
||||
}
|
||||
|
||||
public interface Delegate {
|
||||
|
||||
void showActionsPanel();
|
||||
@@ -153,10 +168,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (myBreakpointComboboxHandler != null) {
|
||||
myBreakpointComboboxHandler.dispose();
|
||||
myBreakpointComboboxHandler = null;
|
||||
}
|
||||
if (myConditionCombo != null) {
|
||||
myConditionCombo.dispose();
|
||||
}
|
||||
@@ -212,7 +223,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
panel.add(component, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public BreakpointPropertiesPanel(Project project, final Key<? extends Breakpoint> breakpointCategory, boolean compact) {
|
||||
public BreakpointPropertiesPanel(final Project project, final Key<? extends Breakpoint> breakpointCategory, boolean compact) {
|
||||
myProject = project;
|
||||
myBreakpointCategory = breakpointCategory;
|
||||
myCompact = compact;
|
||||
@@ -226,7 +237,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
final String defaultPolicy =
|
||||
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().getDefaultSuspendPolicy(breakpointCategory);
|
||||
getBreakpointManager(myProject).getDefaultSuspendPolicy(breakpointCategory);
|
||||
myMakeDefaultButton.setEnabled(!defaultPolicy.equals(getSelectedSuspendPolicy()));
|
||||
}
|
||||
}
|
||||
@@ -247,7 +258,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
myMakeDefaultButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
|
||||
final BreakpointManager breakpointManager = getBreakpointManager(myProject);
|
||||
final String suspendPolicy = getSelectedSuspendPolicy();
|
||||
breakpointManager.setDefaultSuspendPolicy(breakpointCategory, suspendPolicy);
|
||||
updateSuspendPolicyRbFont();
|
||||
@@ -272,20 +283,25 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
myLogExpressionCombo = new DebuggerExpressionComboBox(project, "LineBreakpoint logMessage");
|
||||
|
||||
final ComboBox baseBreakpointCombo = new ComboBox(100);
|
||||
|
||||
myBreakpointComboboxHandler = new BreakpointComboboxHandler(myProject, baseBreakpointCombo);
|
||||
baseBreakpointCombo.setRenderer(new BreakpointComboRenderer(baseBreakpointCombo.getRenderer()));
|
||||
baseBreakpointCombo.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
ComboboxItem item = (ComboboxItem)baseBreakpointCombo.getSelectedItem();
|
||||
myMasterBreakpointChooser = new BreakpointChooser(project, new BreakpointChooser.Delegate() {
|
||||
@Override
|
||||
public void breakpointChosen(Project project, BreakpointItem item, JBPopup popup) {
|
||||
final boolean enabled = item != null && item.getBreakpoint() != null;
|
||||
myLeaveEnabledRadioButton.setEnabled(enabled);
|
||||
myDisableAgainRadio.setEnabled(enabled);
|
||||
myEnableOrDisableLabel.setEnabled(enabled);
|
||||
|
||||
if (item != null) {
|
||||
|
||||
saveMasterBreakpoint();
|
||||
}
|
||||
|
||||
updateMasterBreakpointPanel(findMasterBreakpointRule());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null,
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -341,7 +357,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
insert(myConditionComboPanel, conditionPanel);
|
||||
insert(myLogExpressionComboPanel, myLogExpressionCombo);
|
||||
insert(myDependentBreakpointComboPanel, baseBreakpointCombo);
|
||||
//insert(myDependentBreakpointComboPanel, baseBreakpointCombo);
|
||||
insert(myDependentBreakpointComboPanel, myMasterBreakpointChooser.getComponent());
|
||||
insert(myInstanceFiltersFieldPanel, myInstanceFiltersField);
|
||||
insert(myClassFiltersFieldPanel, myClassFiltersField);
|
||||
|
||||
@@ -364,6 +381,51 @@ public abstract class BreakpointPropertiesPanel {
|
||||
IJSwingUtilities.adjustComponentsOnMac(myLogMessageCheckBox);
|
||||
}
|
||||
|
||||
private List<BreakpointItem> getBreakpointItemsExceptMy() {
|
||||
List<BreakpointItem> items = new ArrayList<BreakpointItem>();
|
||||
findJavaDebuggerSupport().getBreakpointPanelProvider().provideBreakpointItems(myProject, items);
|
||||
for (BreakpointItem item : items) {
|
||||
if (item.getBreakpoint() == myBreakpoint) {
|
||||
items.remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private DebuggerSupport findJavaDebuggerSupport() {
|
||||
DebuggerSupport[] supports = DebuggerSupport.getDebuggerSupports();
|
||||
DebuggerSupport support = null;
|
||||
for (DebuggerSupport s : supports) {
|
||||
if (s instanceof JavaDebuggerSupport) {
|
||||
support = s;
|
||||
}
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
private void saveMasterBreakpoint() {
|
||||
|
||||
|
||||
Breakpoint masterBreakpoint = (Breakpoint)myMasterBreakpointChooser.getSelectedBreakpoint();
|
||||
if (masterBreakpoint == null) {
|
||||
getBreakpointManager(myProject).removeBreakpointRule(myBreakpoint);
|
||||
}
|
||||
else {
|
||||
EnableBreakpointRule rule = findMasterBreakpointRule();
|
||||
boolean selected = myLeaveEnabledRadioButton.isSelected();
|
||||
if (rule != null && (rule.getMasterBreakpoint() != masterBreakpoint || rule.isLeaveEnabled() != selected ) ) {
|
||||
getBreakpointManager(myProject).removeBreakpointRule(rule);
|
||||
|
||||
}
|
||||
getBreakpointManager(myProject).addBreakpointRule(new EnableBreakpointRule(getBreakpointManager(myProject),
|
||||
masterBreakpoint,
|
||||
myBreakpoint,
|
||||
selected));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getSelectedSuspendPolicy() {
|
||||
if (!mySuspendJBCheckBox.isSelected()) {
|
||||
return DebuggerSettings.SUSPEND_NONE;
|
||||
@@ -375,7 +437,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
private void updateSuspendPolicyRbFont() {
|
||||
final String defPolicy = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().getDefaultSuspendPolicy(myBreakpointCategory);
|
||||
final String defPolicy = getBreakpointManager(myProject).getDefaultSuspendPolicy(myBreakpointCategory);
|
||||
|
||||
final Font font = mySuspendAllRadio.getFont().deriveFont(Font.PLAIN);
|
||||
final Font boldFont = font.deriveFont(Font.BOLD);
|
||||
@@ -410,7 +472,9 @@ public abstract class BreakpointPropertiesPanel {
|
||||
myBreakpoint = breakpoint;
|
||||
boolean moreOptionsVisible = moreOptionsVisible1;
|
||||
boolean actionsPanelVisible = moreOptionsVisible1;
|
||||
myBreakpointComboboxHandler.initFrom(breakpoint);
|
||||
|
||||
initMasterBreakpointPanel();
|
||||
|
||||
if (breakpoint.COUNT_FILTER > 0) {
|
||||
myPassCountField.setText(Integer.toString(breakpoint.COUNT_FILTER));
|
||||
moreOptionsVisible = true;
|
||||
@@ -504,6 +568,31 @@ public abstract class BreakpointPropertiesPanel {
|
||||
setMoreOptionsVisible(moreOptionsVisible);
|
||||
}
|
||||
|
||||
private void initMasterBreakpointPanel() {
|
||||
myMasterBreakpointChooser.setBreakpointItems(getBreakpointItemsExceptMy());
|
||||
|
||||
final EnableBreakpointRule rule = findMasterBreakpointRule();
|
||||
|
||||
final Breakpoint baseBreakpoint = rule != null ? rule.getMasterBreakpoint() : null;
|
||||
updateMasterBreakpointPanel(rule);
|
||||
|
||||
myMasterBreakpointChooser.setSelectedBreakpoint(baseBreakpoint);
|
||||
}
|
||||
|
||||
private @Nullable EnableBreakpointRule findMasterBreakpointRule() {
|
||||
return myBreakpoint != null? getBreakpointManager(myProject).findBreakpointRule(myBreakpoint) : null;
|
||||
}
|
||||
|
||||
private void updateMasterBreakpointPanel(@Nullable EnableBreakpointRule rule) {
|
||||
final boolean leaveEnabled = rule != null && rule.isLeaveEnabled();
|
||||
if (leaveEnabled) {
|
||||
myLeaveEnabledRadioButton.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myDisableAgainRadio.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
private TextWithImportsImpl emptyText() {
|
||||
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
|
||||
}
|
||||
@@ -512,7 +601,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
* Save values in the UI components to the breakpoint object
|
||||
*/
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
myBreakpointComboboxHandler.saveTo(breakpoint, myLeaveEnabledRadioButton.isSelected());
|
||||
|
||||
saveMasterBreakpoint();
|
||||
try {
|
||||
String text = myPassCountField.getText().trim();
|
||||
int count = !"".equals(text)? Integer.parseInt(text) : 0;
|
||||
@@ -702,37 +792,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public JPanel getPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
private static class BreakpointComboboxModel extends DefaultComboBoxModel {
|
||||
private final ComboboxItem[] myItems;
|
||||
|
||||
public BreakpointComboboxModel(Breakpoint[] breakpoints) {
|
||||
myItems = new ComboboxItem[breakpoints.length + 1];
|
||||
myItems[0] = new ComboboxItem();
|
||||
for (int idx = 0; idx < breakpoints.length; idx++) {
|
||||
myItems[idx + 1] = new ComboboxItem(breakpoints[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return myItems.length;
|
||||
}
|
||||
|
||||
public ComboboxItem getElementAt(int index) {
|
||||
return myItems[index];
|
||||
}
|
||||
|
||||
public void selectBreakpoint(Breakpoint breakpoint) {
|
||||
for (final ComboboxItem item : myItems) {
|
||||
if (breakpoint == null ? item.getBreakpoint() == null : breakpoint.equals(item.getBreakpoint())) {
|
||||
if (!item.equals(getSelectedItem())) {
|
||||
setSelectedItem(item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ComboboxItem {
|
||||
private final Breakpoint breakpoint;
|
||||
@@ -764,83 +823,9 @@ public abstract class BreakpointPropertiesPanel {
|
||||
return breakpoint != null ? breakpoint.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private class BreakpointComboboxHandler implements BreakpointManagerListener{
|
||||
private final JComboBox myCombo;
|
||||
private final BreakpointManager myBreakpointManager;
|
||||
private Breakpoint myCurrentBreakpoint = null;
|
||||
|
||||
public BreakpointComboboxHandler(final Project project, final JComboBox breakpointCombo) {
|
||||
myCombo = breakpointCombo;
|
||||
myBreakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
|
||||
myBreakpointManager.addBreakpointManagerListener(this);
|
||||
}
|
||||
|
||||
public void initFrom(Breakpoint breakpoint) {
|
||||
myCurrentBreakpoint = breakpoint;
|
||||
fillCombobox();
|
||||
}
|
||||
|
||||
public void saveTo(Breakpoint slaveBreakpoint, final boolean leaveEnabled) {
|
||||
myBreakpointManager.removeBreakpointRule(slaveBreakpoint);
|
||||
final Breakpoint masterBreakpoint = ((ComboboxItem)myCombo.getSelectedItem()).getBreakpoint();
|
||||
if (masterBreakpoint != null) {
|
||||
myBreakpointManager.addBreakpointRule(new EnableBreakpointRule(myBreakpointManager, masterBreakpoint, slaveBreakpoint, leaveEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
public void breakpointsChanged() {
|
||||
fillCombobox();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myBreakpointManager.removeBreakpointManagerListener(this);
|
||||
}
|
||||
|
||||
private void fillCombobox() {
|
||||
final List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(myBreakpointManager.getBreakpoints());
|
||||
if (myCurrentBreakpoint != null) {
|
||||
// avoid depending on itself
|
||||
breakpoints.remove(myCurrentBreakpoint);
|
||||
}
|
||||
myCombo.setModel(new BreakpointComboboxModel(breakpoints.toArray(new Breakpoint[breakpoints.size()])));
|
||||
final EnableBreakpointRule rule = myCurrentBreakpoint != null? myBreakpointManager.findBreakpointRule(myCurrentBreakpoint) : null;
|
||||
final Breakpoint baseBreakpoint = rule != null? rule.getMasterBreakpoint() : null;
|
||||
final boolean leaveEnabled = rule != null && rule.isLeaveEnabled();
|
||||
if (leaveEnabled) {
|
||||
myLeaveEnabledRadioButton.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myDisableAgainRadio.setSelected(true);
|
||||
}
|
||||
((BreakpointComboboxModel)myCombo.getModel()).selectBreakpoint(baseBreakpoint);
|
||||
}
|
||||
}
|
||||
|
||||
private static class BreakpointComboRenderer extends ListCellRendererWrapper {
|
||||
public BreakpointComboRenderer(final ListCellRenderer listCellRenderer) {
|
||||
super(listCellRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
Breakpoint breakpoint = ((ComboboxItem)value).getBreakpoint();
|
||||
final String text = breakpoint != null ? index == -1 ? breakpoint.getShortName() : breakpoint.getDisplayName() : DebuggerBundle.message("value.none");
|
||||
setText(text);
|
||||
|
||||
final Icon icon;
|
||||
if (breakpoint != null) {
|
||||
icon = breakpoint instanceof BreakpointWithHighlighter
|
||||
? breakpoint.ENABLED
|
||||
? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false)
|
||||
: ((BreakpointWithHighlighter)breakpoint).getDisabledIcon(false)
|
||||
: breakpoint.getIcon();
|
||||
}
|
||||
else {
|
||||
icon = null;
|
||||
}
|
||||
setIcon(icon);
|
||||
}
|
||||
private BreakpointManager getBreakpointManager(Project project) {
|
||||
return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
|
||||
}
|
||||
|
||||
private static class MagnifierButtonAction implements ActionListener {
|
||||
|
||||
+21
-7
@@ -23,6 +23,7 @@ import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -37,17 +38,29 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
private final Breakpoint myBreakpoint;
|
||||
private BreakpointFactory myBreakpointFactory;
|
||||
|
||||
public JavaBreakpointItem(BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
|
||||
public JavaBreakpointItem(@Nullable BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
|
||||
myBreakpointFactory = breakpointFactory;
|
||||
myBreakpoint = breakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer) {
|
||||
//renderer.setIcon(myBreakpoint.getIcon());
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
if (plainView) {
|
||||
renderer.setIcon(myBreakpoint.getIcon());
|
||||
}
|
||||
renderer.append(myBreakpoint.getShortName(), isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myBreakpoint.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return myBreakpoint.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return myBreakpoint.getDisplayName();
|
||||
@@ -59,11 +72,12 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetailView(DetailView panel) {
|
||||
BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory
|
||||
.createBreakpointPropertiesPanel(myBreakpoint.getProject(), false);
|
||||
protected void doUpdateDetailView(DetailView panel) {
|
||||
BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory
|
||||
.createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null;
|
||||
if (breakpointPropertiesPanel != null) {
|
||||
breakpointPropertiesPanel.setSaveOnRemove(true);
|
||||
breakpointPropertiesPanel.setDetailView(panel);
|
||||
}
|
||||
|
||||
if (breakpointPropertiesPanel != null) {
|
||||
@@ -86,7 +100,7 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
|
||||
@Override
|
||||
public boolean allowedToRemove() {
|
||||
return myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
|
||||
return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
@@ -44,7 +43,6 @@ public class AnnotationsEditor extends ModuleElementsEditor {
|
||||
private JTable myTable;
|
||||
|
||||
public static final String NAME = ProjectBundle.message("project.roots.external.annotations.tab.title");
|
||||
public static final Icon ICON = AllIcons.Modules.Annotation;
|
||||
|
||||
public AnnotationsEditor(final ModuleConfigurationState state) {
|
||||
super(state);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
@@ -45,7 +44,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class ClasspathEditor extends ModuleElementsEditor implements ModuleRootListener {
|
||||
public static final String NAME = ProjectBundle.message("modules.classpath.title");
|
||||
public static final Icon ICON = AllIcons.Modules.Classpath;
|
||||
|
||||
private ClasspathPanelImpl myPanel;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@@ -46,8 +45,7 @@ import java.util.List;
|
||||
public class JavadocEditor extends ModuleElementsEditor {
|
||||
private JTable myTable;
|
||||
|
||||
public static final String NAME = ProjectBundle.message("module.javadoc.title");
|
||||
public static final Icon ICON = AllIcons.Modules.Javadoc;
|
||||
private static final String NAME = ProjectBundle.message("module.javadoc.title");
|
||||
|
||||
public JavadocEditor(ModuleConfigurationState state) {
|
||||
super(state);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -46,7 +47,12 @@ public class ExpectedTypeInfoImpl implements ExpectedTypeInfo {
|
||||
|
||||
public TailType myTailType;
|
||||
|
||||
public String expectedName;
|
||||
@NotNull public NullableComputable<String> expectedName = new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private PsiMethod myCalledMethod;
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.codeInsight;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -330,14 +331,19 @@ public class ExpectedTypesProvider {
|
||||
}
|
||||
|
||||
@Override public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
PsiMethod scopeMethod = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
|
||||
final PsiMethod scopeMethod = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
|
||||
if (scopeMethod != null) {
|
||||
PsiType type = scopeMethod.getReturnType();
|
||||
if (type != null) {
|
||||
ExpectedTypeInfoImpl info = createInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type,
|
||||
TailType.SEMICOLON);
|
||||
if (PropertyUtil.isSimplePropertyAccessor(scopeMethod)) {
|
||||
info.expectedName = PropertyUtil.getPropertyName(scopeMethod);
|
||||
info.expectedName = new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return PropertyUtil.getPropertyName(scopeMethod);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
myResult = new ExpectedTypeInfo[]{info};
|
||||
@@ -1017,8 +1023,8 @@ public class ExpectedTypesProvider {
|
||||
ExpectedTypeInfoImpl info = createInfoImpl(parameterType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, defaultType, tailType);
|
||||
info.setInsertExplicitTypeParams(true);
|
||||
info.setCalledMethod(method);
|
||||
String propertyName = getPropertyName(parameter);
|
||||
if (propertyName != null) info.expectedName = propertyName;
|
||||
NullableComputable<String> propertyName = getPropertyName(parameter);
|
||||
info.expectedName = propertyName;
|
||||
array.add(info);
|
||||
|
||||
if (index == parameters.length - 1 && parameter.isVarArgs()) {
|
||||
@@ -1158,12 +1164,17 @@ public class ExpectedTypesProvider {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPropertyName(@NotNull PsiVariable variable) {
|
||||
final String name = variable.getName();
|
||||
if (name == null) return null;
|
||||
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(variable.getProject());
|
||||
VariableKind variableKind = codeStyleManager.getVariableKind(variable);
|
||||
return codeStyleManager.variableNameToPropertyName(name, variableKind);
|
||||
private static NullableComputable<String> getPropertyName(@NotNull final PsiVariable variable) {
|
||||
return new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
final String name = variable.getName();
|
||||
if (name == null) return null;
|
||||
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(variable.getProject());
|
||||
VariableKind variableKind = codeStyleManager.getVariableKind(variable);
|
||||
return codeStyleManager.variableNameToPropertyName(name, variableKind);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -247,7 +247,7 @@ public class JavaCompletionSorting {
|
||||
|
||||
private static int calcMatch(final List<String> words, int max, ExpectedTypeInfo[] myExpectedInfos) {
|
||||
for (ExpectedTypeInfo myExpectedInfo : myExpectedInfos) {
|
||||
String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).expectedName;
|
||||
String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).expectedName.compute();
|
||||
if (expectedName == null) continue;
|
||||
max = calcMatch(expectedName, words, max);
|
||||
max = calcMatch(truncDigits(expectedName), words, max);
|
||||
@@ -506,7 +506,7 @@ public class JavaCompletionSorting {
|
||||
int max = 0;
|
||||
final List<String> wordsNoDigits = NameUtil.nameToWordsLowerCase(truncDigits(name));
|
||||
for (ExpectedTypeInfo myExpectedInfo : myExpectedTypes) {
|
||||
String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).expectedName;
|
||||
String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).expectedName.compute();
|
||||
if (expectedName != null) {
|
||||
final THashSet<String> set = new THashSet<String>(NameUtil.nameToWordsLowerCase(truncDigits(expectedName)));
|
||||
set.retainAll(wordsNoDigits);
|
||||
|
||||
+4
-3
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.intention.impl.RunRefactoringAction;
|
||||
import com.intellij.codeInsight.navigation.NavigationUtil;
|
||||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
|
||||
import com.intellij.ide.util.PsiClassListCellRenderer;
|
||||
@@ -163,13 +164,13 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
name+= " and make it abstract";
|
||||
}
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractInterfaceHandler(), "Extract interface"));
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractSuperclassHandler(), "Extract superclass"));
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new ExtractInterfaceHandler(), "Extract interface"));
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new ExtractSuperclassHandler(), "Extract superclass"));
|
||||
}
|
||||
|
||||
|
||||
if (canBePulledUp) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new JavaPullUpHandler(), "Pull members up"));
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new JavaPullUpHandler(), "Pull members up"));
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new PullAsAbstractUpFix(methodWithOverrides, name));
|
||||
}
|
||||
|
||||
+16
-3
@@ -248,7 +248,7 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
PsiParameter[] parms = baseConstructor.getParameterList().getParameters();
|
||||
for (PsiParameter parm : parms) {
|
||||
PsiParameter newParam = factory.createParameter(parm.getName(), parm.getType());
|
||||
copyModifierList(parm, newParam);
|
||||
replaceModifierList(parm, newParam);
|
||||
constructor.getParameterList().add(newParam);
|
||||
}
|
||||
}
|
||||
@@ -291,11 +291,24 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
return constructor;
|
||||
}
|
||||
|
||||
static void copyModifierList(PsiParameter parm, PsiParameter newParam) {
|
||||
static void copyModifierList(JVMElementFactory factory, PsiParameter parm, PsiParameter newParam) {
|
||||
PsiModifierList modifierList = parm.getModifierList();
|
||||
PsiModifierList newMList = newParam.getModifierList();
|
||||
if (modifierList != null && newMList != null) {
|
||||
newMList.replace(modifierList);
|
||||
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
|
||||
newMList.add(factory.createAnnotationFromText(annotation.getText(), newParam));
|
||||
}
|
||||
for (@PsiModifier.ModifierConstant String m : PsiModifier.MODIFIERS) {
|
||||
newMList.setModifierProperty(m, parm.hasModifierProperty(m));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void replaceModifierList(PsiParameter sourceParam, PsiParameter targetParam) {
|
||||
PsiModifierList sourceModifierList = sourceParam.getModifierList();
|
||||
PsiModifierList targetModifierList = targetParam.getModifierList();
|
||||
if (sourceModifierList != null && targetModifierList != null) {
|
||||
targetModifierList.replace(sourceModifierList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ public class GenerateMembersUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
GenerateConstructorHandler.copyModifierList(parameter, newParameter);
|
||||
GenerateConstructorHandler.copyModifierList(factory,parameter, newParameter);
|
||||
}
|
||||
newMethod.getParameterList().add(newParameter);
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public abstract class BaseRunRefactoringAction<T extends RefactoringActionHandler> implements IntentionAction, Iconable, LowPriorityAction {
|
||||
public static final Icon REFACTORING_BULB = AllIcons.Actions.RefactoringBulb;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.refactoring.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Icon getIcon(int flags) {
|
||||
return REFACTORING_BULB;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.encapsulateFields.EncapsulateFieldsHandler;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class EncapsulateFieldAction extends BaseRunRefactoringAction<EncapsulateFieldsHandler> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return CodeInsightBundle.message("intention.encapsulate.field.text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
final PsiField field = getField(getElement(editor, file));
|
||||
return field != null && !field.hasModifierProperty(PsiModifier.FINAL) && !field.hasModifierProperty(PsiModifier.PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final PsiField field = getField(getElement(editor, file));
|
||||
if (field == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
new EncapsulateFieldsHandler().invoke(project, new PsiElement[]{field}, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static PsiField getField(@Nullable PsiElement element) {
|
||||
if (element == null || !(element instanceof PsiIdentifier)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent == null || !(parent instanceof PsiReferenceExpression)) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceExpression ref = (PsiReferenceExpression)parent;
|
||||
final PsiExpression qualifier = ref.getQualifierExpression();
|
||||
if (qualifier == null || qualifier instanceof PsiThisExpression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiElement resolved = ref.resolve();
|
||||
if (resolved == null || !(resolved instanceof PsiField)) {
|
||||
return null;
|
||||
}
|
||||
return (PsiField)resolved;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static PsiElement getElement(Editor editor, @NotNull PsiFile file) {
|
||||
if (!file.getManager().isInProject(file)) return null;
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final int position = caretModel.getOffset();
|
||||
return file.findElementAt(position);
|
||||
}
|
||||
}
|
||||
+3
-17
@@ -16,14 +16,12 @@
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringActionHandlerFactory;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class IntroduceVariableAction implements IntentionAction {
|
||||
public class IntroduceVariableAction extends BaseRunRefactoringAction<IntroduceVariableHandler> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -39,12 +37,6 @@ public class IntroduceVariableAction implements IntentionAction {
|
||||
return CodeInsightBundle.message("intention.introduce.variable.text");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
final PsiElement element = getElement(editor, file);
|
||||
@@ -73,12 +65,6 @@ public class IntroduceVariableAction implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final RefactoringActionHandler refactoringActionHandler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler();
|
||||
refactoringActionHandler.invoke(project, editor, file, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
new IntroduceVariableHandler().invoke(project, editor, file, null);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-27
@@ -13,31 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 9/5/11
|
||||
*/
|
||||
public class RunRefactoringIntention implements IntentionAction, Iconable, LowPriorityAction {
|
||||
public static final Icon REFACTORING_BULB = AllIcons.Actions.RefactoringBulb;
|
||||
public class RunRefactoringAction extends BaseRunRefactoringAction<RefactoringActionHandler> {
|
||||
private final RefactoringActionHandler myHandler;
|
||||
private final String myCommandName;
|
||||
|
||||
public RunRefactoringIntention(RefactoringActionHandler handler, String commandName) {
|
||||
public RunRefactoringAction(RefactoringActionHandler handler, String commandName) {
|
||||
myHandler = handler;
|
||||
myCommandName = commandName;
|
||||
}
|
||||
@@ -48,29 +41,13 @@ public class RunRefactoringIntention implements IntentionAction, Iconable, LowPr
|
||||
return myCommandName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Refactorings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
public final void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
myHandler.invoke(project, editor, file, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return REFACTORING_BULB;
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,14 @@ import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.util.*;
|
||||
|
||||
public class DataFlowRunner {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.DataFlowRunner");
|
||||
private static final Key<Integer> TOO_EXPENSIVE_SIZE = Key.create("TOO_EXPENSIVE_SIZE");
|
||||
private static final long ourTimeLimit = 1000;
|
||||
public static final long ourTimeLimit = 1000 * 1000 * 1000; //1 sec in nanoseconds
|
||||
|
||||
private Instruction[] myInstructions;
|
||||
private DfaVariableValue[] myFields;
|
||||
@@ -121,10 +123,11 @@ public class DataFlowRunner {
|
||||
|
||||
long timeLimit = ourTimeLimit;
|
||||
final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
final long before = System.currentTimeMillis();
|
||||
ThreadMXBean tm = ManagementFactory.getThreadMXBean();
|
||||
final long before = tm.getCurrentThreadUserTime();
|
||||
int count = 0;
|
||||
while (!queue.isEmpty()) {
|
||||
if (count % 50 == 0 && !unitTestMode && System.currentTimeMillis() - before > timeLimit) {
|
||||
if (count % 50 == 0 && !unitTestMode && tm.getCurrentThreadUserTime() - before > timeLimit) {
|
||||
psiBlock.putUserData(TOO_EXPENSIVE_SIZE, psiBlock.getText().hashCode());
|
||||
return RunnerResult.TOO_COMPLEX;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
|
||||
}
|
||||
|
||||
private static class IconHolder {
|
||||
private static final Icon JAVA_MODULE_ICON = AllIcons.Modules.JavaModule;
|
||||
private static final Icon JAVA_MODULE_ICON = AllIcons.Modules.Types.JavaModule;
|
||||
}
|
||||
|
||||
private static Icon getJavaModuleIcon() {
|
||||
|
||||
@@ -40,6 +40,18 @@ public class PsiDiamondTypeUtil {
|
||||
public static boolean canCollapseToDiamond(final PsiNewExpression expression,
|
||||
final PsiNewExpression context,
|
||||
final @Nullable PsiType expectedType) {
|
||||
return canCollapseToDiamond(expression, context, expectedType, false);
|
||||
}
|
||||
|
||||
public static boolean canChangeContextForDiamond(final PsiNewExpression expression, final PsiType expectedType) {
|
||||
final PsiNewExpression copy = (PsiNewExpression)expression.copy();
|
||||
return canCollapseToDiamond(copy, copy, expectedType, true);
|
||||
}
|
||||
|
||||
private static boolean canCollapseToDiamond(final PsiNewExpression expression,
|
||||
final PsiNewExpression context,
|
||||
final @Nullable PsiType expectedType,
|
||||
boolean skipDiamonds) {
|
||||
if (PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_1_7)) {
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null) {
|
||||
@@ -47,7 +59,7 @@ public class PsiDiamondTypeUtil {
|
||||
if (parameterList != null) {
|
||||
final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements();
|
||||
if (typeElements.length > 0) {
|
||||
if (typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return false;
|
||||
if (!skipDiamonds && typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return false;
|
||||
final PsiDiamondTypeImpl.DiamondInferenceResult inferenceResult = PsiDiamondTypeImpl.resolveInferredTypes(expression, context);
|
||||
if (inferenceResult.getErrorMessage() == null) {
|
||||
final List<PsiType> types = inferenceResult.getInferredTypes();
|
||||
|
||||
@@ -138,10 +138,14 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
|
||||
private static void fillResultsMap(Map<PsiFile, PsiClass[]> result, PsiFile containingFile, PsiClass[] topLevelClasses) {
|
||||
PsiClass[] classes = result.get(containingFile);
|
||||
if (classes != null) {
|
||||
topLevelClasses = ArrayUtil.mergeArrays(classes, topLevelClasses, PsiClass.ARRAY_FACTORY);
|
||||
if (topLevelClasses != null) {
|
||||
if (classes != null) {
|
||||
topLevelClasses = ArrayUtil.mergeArrays(classes, topLevelClasses, PsiClass.ARRAY_FACTORY);
|
||||
}
|
||||
result.put(containingFile, topLevelClasses);
|
||||
} else {
|
||||
result.put(containingFile, classes);
|
||||
}
|
||||
result.put(containingFile, topLevelClasses);
|
||||
}
|
||||
|
||||
public void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
|
||||
|
||||
+3
-1
@@ -94,7 +94,9 @@ public class JavaIntroduceParameterMethodUsagesProcessor implements IntroducePar
|
||||
ExpressionConverter.getExpression(data.getParameterInitializer().getExpression(), StdLanguages.JAVA, data.getProject());
|
||||
assert initializer instanceof PsiExpression;
|
||||
if (initializer instanceof PsiNewExpression) {
|
||||
initializer = PsiDiamondTypeUtil.expandTopLevelDiamondsInside((PsiNewExpression)initializer);
|
||||
if (!PsiDiamondTypeUtil.canChangeContextForDiamond((PsiNewExpression)initializer, ((PsiNewExpression)initializer).getType())) {
|
||||
initializer = PsiDiamondTypeUtil.expandTopLevelDiamondsInside((PsiNewExpression)initializer);
|
||||
}
|
||||
}
|
||||
substituteTypeParametersInInitializer(initializer, callExpression, argList, methodToSearchFor);
|
||||
ChangeContextUtil.encodeContextInfo(initializer, true);
|
||||
|
||||
@@ -175,7 +175,11 @@ public class RefactoringUtil {
|
||||
public int compare(final UsageInfo usage1, final UsageInfo usage2) {
|
||||
final PsiElement element1 = usage1.getElement();
|
||||
final PsiElement element2 = usage2.getElement();
|
||||
if (element1 == null || element2 == null) return 0;
|
||||
if (element1 == null) {
|
||||
if (element2 == null) return 0;
|
||||
return 1;
|
||||
}
|
||||
if (element2 == null) return -1;
|
||||
return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,6 +22,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Represents a Java lambda expression.
|
||||
*/
|
||||
public interface PsiLambdaExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns this lambda expression's type parameter list (if any).
|
||||
*
|
||||
* @return type parameter list or null.
|
||||
*/
|
||||
@Nullable
|
||||
PsiTypeParameterList getTypeParameterList();
|
||||
|
||||
/**
|
||||
* Returns this lambda expression's parameter list.
|
||||
*
|
||||
@@ -31,7 +39,8 @@ public interface PsiLambdaExpression extends PsiExpression {
|
||||
PsiParameterList getParameterList();
|
||||
|
||||
/**
|
||||
* Returns PSI element representing lambda expression body: {@link PsiCodeBlock}, {@link PsiExpression}, or null if none.
|
||||
* Returns PSI element representing lambda expression body: {@link PsiCodeBlock}, {@link PsiExpression},
|
||||
* or null if the expression is incomplete.
|
||||
*
|
||||
* @return lambda expression body.
|
||||
*/
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ExpressionParser {
|
||||
return parseBinary(builder, ExprType.UNARY, MULTIPLICATIVE_OPS);
|
||||
|
||||
case UNARY:
|
||||
return parseUnary(builder);
|
||||
return parseUnary(builder, false);
|
||||
|
||||
case TYPE:
|
||||
return myParser.getReferenceParser().parseType(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD);
|
||||
@@ -246,14 +246,14 @@ public class ExpressionParser {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parseUnary(final PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parseUnary(final PsiBuilder builder, final boolean afterCast) {
|
||||
final IElementType tokenType = builder.getTokenType();
|
||||
|
||||
if (PREFIX_OPS.contains(tokenType)) {
|
||||
final PsiBuilder.Marker unary = builder.mark();
|
||||
builder.advanceLexer();
|
||||
|
||||
final PsiBuilder.Marker operand = parseUnary(builder);
|
||||
final PsiBuilder.Marker operand = parseUnary(builder, false);
|
||||
if (operand == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.expression"));
|
||||
}
|
||||
@@ -269,19 +269,19 @@ public class ExpressionParser {
|
||||
myParser.getReferenceParser().parseTypeInfo(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD);
|
||||
if (typeInfo == null || !expect(builder, JavaTokenType.RPARENTH)) {
|
||||
typeCast.rollbackTo();
|
||||
return parsePostfix(builder);
|
||||
return parsePostfix(builder, false);
|
||||
}
|
||||
|
||||
if (PREF_ARITHMETIC_OPS.contains(builder.getTokenType()) && !typeInfo.isPrimitive) {
|
||||
typeCast.rollbackTo();
|
||||
return parsePostfix(builder);
|
||||
return parsePostfix(builder, false);
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker expr = parseUnary(builder);
|
||||
final PsiBuilder.Marker expr = parseUnary(builder, true);
|
||||
if (expr == null) {
|
||||
if (!typeInfo.isParameterized) { // cannot parse correct parenthesized expression after correct parameterized type
|
||||
typeCast.rollbackTo();
|
||||
return parsePostfix(builder);
|
||||
return parsePostfix(builder, false);
|
||||
}
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.expression"));
|
||||
@@ -292,13 +292,13 @@ public class ExpressionParser {
|
||||
return typeCast;
|
||||
}
|
||||
else {
|
||||
return parsePostfix(builder);
|
||||
return parsePostfix(builder, afterCast);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parsePostfix(final PsiBuilder builder) {
|
||||
PsiBuilder.Marker operand = parsePrimary(builder, null, -1);
|
||||
private PsiBuilder.Marker parsePostfix(final PsiBuilder builder, final boolean afterCast) {
|
||||
PsiBuilder.Marker operand = parsePrimary(builder, null, -1, afterCast);
|
||||
if (operand == null) return null;
|
||||
|
||||
while (POSTFIX_OPS.contains(builder.getTokenType())) {
|
||||
@@ -315,10 +315,13 @@ public class ExpressionParser {
|
||||
|
||||
// todo[r.sh] make 'this', 'super' and 'class' reference expressions
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parsePrimary(final PsiBuilder builder, @Nullable final BreakPoint breakPoint, final int breakOffset) {
|
||||
private PsiBuilder.Marker parsePrimary(final PsiBuilder builder,
|
||||
@Nullable final BreakPoint breakPoint,
|
||||
final int breakOffset,
|
||||
final boolean afterCast) {
|
||||
PsiBuilder.Marker startMarker = builder.mark();
|
||||
|
||||
PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder);
|
||||
PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder, afterCast);
|
||||
if (expr == null) {
|
||||
startMarker.drop();
|
||||
return null;
|
||||
@@ -346,7 +349,7 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker classObjAccess = parseClassAccessOrMethodReference(builder);
|
||||
if (classObjAccess == null || builder.getCurrentOffset() < offset) {
|
||||
copy.rollbackTo();
|
||||
return parsePrimary(builder, BreakPoint.P1, offset);
|
||||
return parsePrimary(builder, BreakPoint.P1, offset, false);
|
||||
}
|
||||
|
||||
startMarker = copy;
|
||||
@@ -370,13 +373,13 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false, false);
|
||||
if (ref == null || builder.getTokenType() != JavaTokenType.DOT || builder.getCurrentOffset() != dotOffset) {
|
||||
copy.rollbackTo();
|
||||
return parsePrimary(builder, BreakPoint.P2, offset);
|
||||
return parsePrimary(builder, BreakPoint.P2, offset, false);
|
||||
}
|
||||
builder.advanceLexer();
|
||||
|
||||
if (builder.getTokenType() != dotTokenType) {
|
||||
copy.rollbackTo();
|
||||
return parsePrimary(builder, BreakPoint.P2, offset);
|
||||
return parsePrimary(builder, BreakPoint.P2, offset, false);
|
||||
}
|
||||
builder.advanceLexer();
|
||||
|
||||
@@ -417,7 +420,7 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker copy = startMarker.precede();
|
||||
startMarker.rollbackTo();
|
||||
|
||||
final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder);
|
||||
final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder, false);
|
||||
if (qualifier != null) {
|
||||
final PsiBuilder.Marker refExpr = qualifier.precede();
|
||||
if (builder.getTokenType() == JavaTokenType.DOT) {
|
||||
@@ -433,7 +436,7 @@ public class ExpressionParser {
|
||||
}
|
||||
|
||||
copy.rollbackTo();
|
||||
return parsePrimary(builder, BreakPoint.P3, -1);
|
||||
return parsePrimary(builder, BreakPoint.P3, -1, false);
|
||||
}
|
||||
else {
|
||||
startMarker.drop();
|
||||
@@ -462,7 +465,7 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker classObjAccess = parseClassAccessOrMethodReference(builder);
|
||||
if (classObjAccess == null || builder.getCurrentOffset() <= pos) {
|
||||
copy.rollbackTo();
|
||||
return parsePrimary(builder, BreakPoint.P4, -1);
|
||||
return parsePrimary(builder, BreakPoint.P4, -1, false);
|
||||
}
|
||||
|
||||
startMarker = copy;
|
||||
@@ -502,7 +505,7 @@ public class ExpressionParser {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parsePrimaryExpressionStart(final PsiBuilder builder) {
|
||||
private PsiBuilder.Marker parsePrimaryExpressionStart(final PsiBuilder builder, final boolean afterCast) {
|
||||
IElementType tokenType = builder.getTokenType();
|
||||
|
||||
if (LITERALS.contains(tokenType)) {
|
||||
@@ -512,21 +515,21 @@ public class ExpressionParser {
|
||||
return literal;
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.LBRACE) {
|
||||
return parseArrayInitializer(builder);
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.NEW_KEYWORD) {
|
||||
return parseNew(builder, null);
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.LPARENTH) {
|
||||
final PsiBuilder.Marker lambda = parseLambdaAfterParenth(builder, null);
|
||||
if (lambda != null) {
|
||||
return lambda;
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker parenth = builder.mark();
|
||||
|
||||
final IElementType nextToken1 = builder.lookAhead(1);
|
||||
final IElementType nextToken2 = builder.lookAhead(2);
|
||||
if (nextToken1 == JavaTokenType.IDENTIFIER) {
|
||||
if (nextToken2 == JavaTokenType.COMMA ||
|
||||
nextToken2 == JavaTokenType.RPARENTH && builder.lookAhead(3) == JavaTokenType.ARROW) {
|
||||
return parseLambdaExpression(builder, parenth, false);
|
||||
}
|
||||
}
|
||||
else if (nextToken1 == JavaTokenType.RPARENTH && nextToken2 == JavaTokenType.ARROW) {
|
||||
return parseLambdaExpression(builder, parenth, false);
|
||||
}
|
||||
|
||||
builder.advanceLexer();
|
||||
|
||||
final PsiBuilder.Marker inner = parse(builder);
|
||||
@@ -544,17 +547,15 @@ public class ExpressionParser {
|
||||
return parenth;
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.LBRACE) {
|
||||
return parseArrayInitializer(builder);
|
||||
}
|
||||
|
||||
if (TYPE_START.contains(tokenType)) {
|
||||
final PsiBuilder.Marker mark = builder.mark();
|
||||
|
||||
final ReferenceParser.TypeInfo typeInfo = myParser.getReferenceParser().parseTypeInfo(builder, 0);
|
||||
if (typeInfo != null && (typeInfo.isPrimitive || !typeInfo.hasErrors && typeInfo.isParameterized)) {
|
||||
final PsiBuilder.Marker result = continueClassAccessOrMethodReference(builder, mark, typeInfo.isPrimitive);
|
||||
if (result != null) return result;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
mark.rollbackTo();
|
||||
@@ -568,7 +569,7 @@ public class ExpressionParser {
|
||||
|
||||
if (tokenType == JavaTokenType.IDENTIFIER) {
|
||||
if (builder.lookAhead(1) == JavaTokenType.ARROW) {
|
||||
return parseLambdaExpression(builder, builder.mark(), false);
|
||||
return parseLambdaExpression(builder, false, null);
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker refExpr;
|
||||
@@ -596,6 +597,29 @@ public class ExpressionParser {
|
||||
if (tokenType == JavaTokenType.LT) {
|
||||
expr = builder.mark();
|
||||
|
||||
if (!afterCast) {
|
||||
final PsiBuilder.Marker typeParams = myParser.getReferenceParser().parseTypeParameters(builder, true);
|
||||
|
||||
if (typeParams != null) {
|
||||
tokenType = builder.getTokenType();
|
||||
|
||||
PsiBuilder.Marker lambda = null;
|
||||
if (tokenType == JavaTokenType.LPARENTH) {
|
||||
lambda = parseLambdaAfterParenth(builder, typeParams);
|
||||
}
|
||||
else if (tokenType == JavaTokenType.IDENTIFIER && builder.lookAhead(1) == JavaTokenType.ARROW) {
|
||||
lambda = parseLambdaExpression(builder, false, typeParams);
|
||||
}
|
||||
if (lambda != null) {
|
||||
expr.drop();
|
||||
return lambda;
|
||||
}
|
||||
|
||||
expr.rollbackTo();
|
||||
expr = builder.mark();
|
||||
}
|
||||
}
|
||||
|
||||
if (!myParser.getReferenceParser().parseReferenceParameterList(builder, false, false)) {
|
||||
expr.rollbackTo();
|
||||
return null;
|
||||
@@ -622,10 +646,6 @@ public class ExpressionParser {
|
||||
return expr;
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.NEW_KEYWORD) {
|
||||
return parseNew(builder, null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -827,15 +847,75 @@ public class ExpressionParser {
|
||||
return start;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiBuilder.Marker parseLambdaExpression(final PsiBuilder builder, final PsiBuilder.Marker start, final boolean typed) {
|
||||
myParser.getDeclarationParser().parseLambdaParameterList(builder, typed);
|
||||
return parseLambdaExpressionFromArrow(builder, start);
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parseLambdaAfterParenth(final PsiBuilder builder, @Nullable final PsiBuilder.Marker typeList) {
|
||||
final boolean isLambda;
|
||||
final boolean isTyped;
|
||||
|
||||
final IElementType nextToken1 = builder.lookAhead(1);
|
||||
final IElementType nextToken2 = builder.lookAhead(2);
|
||||
if (nextToken1 == JavaTokenType.RPARENTH && nextToken2 == JavaTokenType.ARROW) {
|
||||
isLambda = true;
|
||||
isTyped = false;
|
||||
}
|
||||
else if (nextToken1 == JavaTokenType.AT ||
|
||||
ElementType.MODIFIER_BIT_SET.contains(nextToken1) || ElementType.PRIMITIVE_TYPE_BIT_SET.contains(nextToken1)) {
|
||||
isLambda = true;
|
||||
isTyped = true;
|
||||
}
|
||||
else if (nextToken1 == JavaTokenType.IDENTIFIER) {
|
||||
if (nextToken2 == JavaTokenType.COMMA || nextToken2 == JavaTokenType.RPARENTH && builder.lookAhead(3) == JavaTokenType.ARROW) {
|
||||
isLambda = true;
|
||||
isTyped = false;
|
||||
}
|
||||
else if (nextToken2 == JavaTokenType.ARROW) {
|
||||
isLambda = false;
|
||||
isTyped = false;
|
||||
}
|
||||
else {
|
||||
boolean arrow = false;
|
||||
|
||||
final PsiBuilder.Marker marker = builder.mark();
|
||||
while (!builder.eof()) {
|
||||
builder.advanceLexer();
|
||||
final IElementType tokenType = builder.getTokenType();
|
||||
if (tokenType == JavaTokenType.ARROW) {
|
||||
arrow = true;
|
||||
break;
|
||||
}
|
||||
if (tokenType == JavaTokenType.RPARENTH) {
|
||||
arrow = builder.lookAhead(1) == JavaTokenType.ARROW;
|
||||
break;
|
||||
}
|
||||
else if (tokenType == JavaTokenType.LPARENTH || tokenType == JavaTokenType.SEMICOLON ||
|
||||
tokenType == JavaTokenType.LBRACE || tokenType == JavaTokenType.RBRACE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
marker.rollbackTo();
|
||||
|
||||
isLambda = arrow;
|
||||
isTyped = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isLambda = false;
|
||||
isTyped = false;
|
||||
}
|
||||
|
||||
return isLambda ? parseLambdaExpression(builder, isTyped, typeList) : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiBuilder.Marker parseLambdaExpressionFromArrow(final PsiBuilder builder, final PsiBuilder.Marker start) {
|
||||
builder.advanceLexer();
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parseLambdaExpression(final PsiBuilder builder, final boolean typed, @Nullable final PsiBuilder.Marker typeList) {
|
||||
final PsiBuilder.Marker start = typeList != null ? typeList.precede() : builder.mark();
|
||||
|
||||
myParser.getDeclarationParser().parseLambdaParameterList(builder, typed);
|
||||
|
||||
if (!expect(builder, JavaTokenType.ARROW)) {
|
||||
start.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker body;
|
||||
if (builder.getTokenType() == JavaTokenType.LBRACE) {
|
||||
|
||||
@@ -297,6 +297,13 @@ public class ReferenceParser {
|
||||
|
||||
@NotNull
|
||||
public PsiBuilder.Marker parseTypeParameters(final PsiBuilder builder) {
|
||||
final PsiBuilder.Marker marker = parseTypeParameters(builder, false);
|
||||
assert marker != null;
|
||||
return marker;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiBuilder.Marker parseTypeParameters(final PsiBuilder builder, final boolean stopOnErrors) {
|
||||
final PsiBuilder.Marker list = builder.mark();
|
||||
if (!expect(builder, JavaTokenType.LT)) {
|
||||
list.done(JavaElementType.TYPE_PARAMETER_LIST);
|
||||
@@ -306,6 +313,10 @@ public class ReferenceParser {
|
||||
while (true) {
|
||||
final PsiBuilder.Marker param = parseTypeParameter(builder);
|
||||
if (param == null) {
|
||||
if (stopOnErrors) {
|
||||
list.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
error(builder, JavaErrorMessages.message("expected.type.parameter"));
|
||||
}
|
||||
if (!expect(builder, JavaTokenType.COMMA)) {
|
||||
@@ -314,6 +325,11 @@ public class ReferenceParser {
|
||||
}
|
||||
|
||||
if (!expect(builder, JavaTokenType.GT)) {
|
||||
if (stopOnErrors) {
|
||||
list.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
// hack for completion
|
||||
if (builder.getTokenType() == JavaTokenType.IDENTIFIER) {
|
||||
if (builder.lookAhead(1) == JavaTokenType.GT) {
|
||||
|
||||
@@ -184,14 +184,39 @@ public class PsiImplUtil {
|
||||
@NotNull final ResolveState state,
|
||||
final PsiElement lastParent,
|
||||
@NotNull final PsiElement place) {
|
||||
final boolean fromBody = lastParent instanceof PsiCodeBlock;
|
||||
final PsiTypeParameterList typeParameterList = method.getTypeParameterList();
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
return processDeclarationsInMethodLike(method, processor, state, fromBody, place, typeParameterList, parameterList);
|
||||
}
|
||||
|
||||
public static boolean processDeclarationsInLambda(@NotNull final PsiLambdaExpression lambda,
|
||||
@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull final ResolveState state,
|
||||
final PsiElement lastParent,
|
||||
@NotNull final PsiElement place) {
|
||||
final boolean fromBody = lastParent != null && lastParent == lambda.getBody();
|
||||
final PsiTypeParameterList typeParameterList = lambda.getTypeParameterList();
|
||||
final PsiParameterList parameterList = lambda.getParameterList();
|
||||
return processDeclarationsInMethodLike(lambda, processor, state, fromBody, place, typeParameterList, parameterList);
|
||||
}
|
||||
|
||||
private static boolean processDeclarationsInMethodLike(@NotNull final PsiElement element,
|
||||
@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull final ResolveState state,
|
||||
final boolean fromBody,
|
||||
@NotNull final PsiElement place,
|
||||
@Nullable final PsiTypeParameterList typeParameterList,
|
||||
@NotNull final PsiParameterList parameterList) {
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, element);
|
||||
|
||||
final ElementClassHint hint = processor.getHint(ElementClassHint.KEY);
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, method);
|
||||
if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) {
|
||||
final PsiTypeParameterList list = method.getTypeParameterList();
|
||||
if (list != null && !list.processDeclarations(processor, state, null, place)) return false;
|
||||
if (typeParameterList != null && !typeParameterList.processDeclarations(processor, state, null, place)) return false;
|
||||
}
|
||||
if (lastParent instanceof PsiCodeBlock) {
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
|
||||
if (fromBody) {
|
||||
final PsiParameter[] parameters = parameterList.getParameters();
|
||||
for (PsiParameter parameter : parameters) {
|
||||
if (!processor.execute(parameter, state)) return false;
|
||||
}
|
||||
|
||||
@@ -63,22 +63,24 @@ public class JavaLightStubBuilder extends LightStubBuilder {
|
||||
if (child instanceof ASTNodeBuilder.ASTUnparsedNodeMarker) {
|
||||
ASTNodeBuilder.ASTUnparsedNodeMarker nodeMarker = (ASTNodeBuilder.ASTUnparsedNodeMarker)child;
|
||||
final ASTNodeBuilder nodeBuilder = nodeMarker.getBuilder();
|
||||
final int endLexemIndex = nodeMarker.getEndLexemIndex();
|
||||
final int endLexemeIndex = nodeMarker.getEndLexemeIndex();
|
||||
boolean seenNew = false;
|
||||
|
||||
for(int i = nodeMarker.getStartLexemIndex(); i < endLexemIndex; ++i) {
|
||||
for (int i = nodeMarker.getStartLexemeIndex(); i < endLexemeIndex; ++i) {
|
||||
final IElementType type = nodeBuilder.getElementType(i);
|
||||
if (type == JavaTokenType.NEW_KEYWORD) {
|
||||
seenNew = true;
|
||||
} else if (seenNew && type == JavaTokenType.LBRACE) {
|
||||
}
|
||||
else if (seenNew && type == JavaTokenType.LBRACE) {
|
||||
return false;
|
||||
} else if (seenNew && type == JavaTokenType.SEMICOLON) {
|
||||
}
|
||||
else if (seenNew && type == JavaTokenType.SEMICOLON) {
|
||||
seenNew = false;
|
||||
} else if (type == JavaTokenType.AT || // local vars can be annotated and we have them in stubs!
|
||||
type == JavaTokenType.CLASS_KEYWORD || // local classes
|
||||
type == JavaTokenType.INTERFACE_KEYWORD ||
|
||||
type == JavaTokenType.ENUM_KEYWORD
|
||||
) {
|
||||
}
|
||||
else if (type == JavaTokenType.AT || // local vars can be annotated and we have them in stubs!
|
||||
type == JavaTokenType.CLASS_KEYWORD || // local classes
|
||||
type == JavaTokenType.INTERFACE_KEYWORD ||
|
||||
type == JavaTokenType.ENUM_KEYWORD) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-2
@@ -16,7 +16,9 @@
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -25,16 +27,22 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
super(JavaElementType.LAMBDA_EXPRESSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeParameterList getTypeParameterList() {
|
||||
final PsiElement element = getFirstChild();
|
||||
return element instanceof PsiTypeParameterList ? (PsiTypeParameterList)element : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiParameterList getParameterList() {
|
||||
return PsiTreeUtil.getRequiredChildOfType(this, PsiParameterList.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PsiElement getBody() {
|
||||
return PsiTreeUtil.getChildOfAnyType(this, PsiExpression.class, PsiCodeBlock.class);
|
||||
final PsiElement element = getLastChild();
|
||||
return element instanceof PsiExpression || element instanceof PsiCodeBlock ? element : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +60,14 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDeclarations(@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull final ResolveState state,
|
||||
final PsiElement lastParent,
|
||||
@NotNull final PsiElement place) {
|
||||
return PsiImplUtil.processDeclarationsInLambda(this, processor, state, lastParent, place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiLambdaExpression:" + getText();
|
||||
|
||||
+13
-1
@@ -14,15 +14,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
interface Simplest {
|
||||
void m();
|
||||
}
|
||||
void simplest() { }
|
||||
void use(Simplest s) { }
|
||||
|
||||
interface IntParser {
|
||||
int parse(String s);
|
||||
}
|
||||
|
||||
interface ListProducer<T> {
|
||||
List<T> produce();
|
||||
}
|
||||
|
||||
void test() {
|
||||
Simplest simplest = <weak_warning descr="Lambda expressions type check is not yet implemented">() -> { }</weak_warning>;
|
||||
use(<weak_warning descr="Lambda expressions type check is not yet implemented">() -> { }</weak_warning>);
|
||||
|
||||
IntParser intParser = <weak_warning descr="Lambda expressions type check is not yet implemented">(String s) -> Integer.parseInt(s)</weak_warning>;
|
||||
ListProducer<String> listProducer = <weak_warning descr="Lambda expressions type check is not yet implemented"><T>() -> new ArrayList<T>()</weak_warning>;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Encapsulate field" "false"
|
||||
|
||||
class A {
|
||||
public final boolean m_bool;
|
||||
}
|
||||
|
||||
public class B {
|
||||
void method() {
|
||||
A a = new A();
|
||||
|
||||
a.m_bo<caret>ol = true;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Encapsulate field" "false"
|
||||
|
||||
class A {
|
||||
private boolean m_bool;
|
||||
}
|
||||
|
||||
public class B {
|
||||
void method() {
|
||||
A a = new A();
|
||||
|
||||
a.m_bo<caret>ol = true;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Encapsulate field" "false"
|
||||
|
||||
class A {
|
||||
public final boolean m_bool;
|
||||
|
||||
void method() {
|
||||
m_bo<caret>ol = true;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Encapsulate field" "false"
|
||||
|
||||
class A {
|
||||
public final boolean m_bool;
|
||||
|
||||
void method() {
|
||||
this.m_bo<caret>ol = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
PsiJavaFile:AmbiguousLambdaExpression.java
|
||||
PsiMethodCallExpression:f( (x) < y , z > (w) -> v )
|
||||
PsiReferenceExpression:f
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:f('f')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBinaryExpression:(x) < y
|
||||
PsiParenthesizedExpression:(x)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiReferenceExpression:x
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:x('x')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LT('<')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:y
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:y('y')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBinaryExpression:z > (w) -> v
|
||||
PsiReferenceExpression:z
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:z('z')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLambdaExpression:(w) -> v
|
||||
PsiParameterList:(w)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:w
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiIdentifier:w('w')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:v
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:v('v')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
@@ -0,0 +1,33 @@
|
||||
PsiJavaFile:LambdaExpression12.java
|
||||
PsiLambdaExpression:<T>() -> new C<T>()
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiParameterList:()
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiNewExpression:new C<T>()
|
||||
PsiKeyword:new('new')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:C<T>
|
||||
PsiIdentifier:C('C')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:T
|
||||
PsiJavaCodeReferenceElement:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
@@ -0,0 +1,21 @@
|
||||
PsiJavaFile:LambdaExpression13.java
|
||||
PsiLambdaExpression:<T>t -> t
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiParameterList:t
|
||||
PsiParameter:t
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiIdentifier:t('t')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:t
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:t('t')
|
||||
@@ -0,0 +1,22 @@
|
||||
PsiJavaFile:LambdaExpression14.java
|
||||
PsiLambdaExpression:(String t) -> t
|
||||
PsiParameterList:(String t)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:t
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
PsiIdentifier:String('String')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:t('t')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:t
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:t('t')
|
||||
@@ -0,0 +1,36 @@
|
||||
PsiJavaFile:LambdaExpression15.java
|
||||
PsiLambdaExpression:(int a, int b) -> a + b
|
||||
PsiParameterList:(int a, int b)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:a
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:int
|
||||
PsiKeyword:int('int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:a('a')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiParameter:b
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:int
|
||||
PsiKeyword:int('int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:b('b')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBinaryExpression:a + b
|
||||
PsiReferenceExpression:a
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:a('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:PLUS('+')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:b
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:b('b')
|
||||
@@ -0,0 +1,20 @@
|
||||
PsiJavaFile:LambdaExpression16.java
|
||||
PsiLambdaExpression:(final int x) -> x
|
||||
PsiParameterList:(final int x)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:x
|
||||
PsiModifierList:final
|
||||
PsiKeyword:final('final')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:int
|
||||
PsiKeyword:int('int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:x('x')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:x
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:x('x')
|
||||
@@ -0,0 +1,23 @@
|
||||
PsiJavaFile:LambdaExpression17.java
|
||||
PsiLambdaExpression:(String s -> s
|
||||
PsiParameterList:(String s
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:s
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
PsiIdentifier:String('String')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:s('s')
|
||||
PsiErrorElement:')' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:s
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:s('s')
|
||||
@@ -0,0 +1,34 @@
|
||||
PsiJavaFile:LambdaExpression18.java
|
||||
PsiLambdaExpression:(java.lang.String s, -> s
|
||||
PsiParameterList:(java.lang.String s,
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:s
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:java.lang.String
|
||||
PsiJavaCodeReferenceElement:java.lang.String
|
||||
PsiJavaCodeReferenceElement:java.lang
|
||||
PsiJavaCodeReferenceElement:java
|
||||
PsiIdentifier:java('java')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiIdentifier:lang('lang')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiIdentifier:String('String')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:s('s')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiErrorElement:Parameter expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:s
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:s('s')
|
||||
@@ -0,0 +1,31 @@
|
||||
PsiJavaFile:LambdaExpression19.java
|
||||
PsiLambdaExpression:(@A T t) -> (null)
|
||||
PsiParameterList:(@A T t)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiParameter:t
|
||||
PsiModifierList:@A
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:A
|
||||
PsiIdentifier:A('A')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:T
|
||||
PsiJavaCodeReferenceElement:T
|
||||
PsiIdentifier:T('T')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:t('t')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiParenthesizedExpression:(null)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiLiteralExpression:null
|
||||
PsiJavaToken:NULL_KEYWORD('null')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public static <T, V> ParallelPipeline<T, V> test(T base, V newStage, T upstream, final ParallelPipeline<T, V> anObject) {
|
||||
if (base != null){
|
||||
return anObject;
|
||||
}
|
||||
else {
|
||||
return new ParallelPipeline<>(upstream, newStage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void f() {
|
||||
test(null, null, null, new ParallelPipeline<>(null, null));
|
||||
}
|
||||
private static class ParallelPipeline<T, V> {
|
||||
public ParallelPipeline(T p0, V p1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public static <T, V> ParallelPipeline<T, V> test(T base, V newStage, T upstream) {
|
||||
if (base != null){
|
||||
return <selection>new ParallelPipeline<>(base, newStage)</selection>;
|
||||
}
|
||||
else {
|
||||
return new ParallelPipeline<>(upstream, newStage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void f() {
|
||||
test(null, null, null);
|
||||
}
|
||||
private static class ParallelPipeline<T, V> {
|
||||
public ParallelPipeline(T p0, V p1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class EncapsulateFieldTest extends LightIntentionActionTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField";
|
||||
}
|
||||
}
|
||||
+10
@@ -134,6 +134,16 @@ public class ExpressionParserTest extends JavaParsingTestCase {
|
||||
public void testLambdaExpression9() { doParserTest("(I)p -> null"); }
|
||||
public void testLambdaExpression10() { doParserTest("(I)(p -> null)"); }
|
||||
public void testLambdaExpression11() { doParserTest("() -> { }"); }
|
||||
public void testLambdaExpression12() { doParserTest("<T>() -> new C<T>()"); }
|
||||
public void testLambdaExpression13() { doParserTest("<T>t -> t"); }
|
||||
public void testLambdaExpression14() { doParserTest("(String t) -> t"); }
|
||||
public void testLambdaExpression15() { doParserTest("(int a, int b) -> a + b"); }
|
||||
public void testLambdaExpression16() { doParserTest("(final int x) -> x"); }
|
||||
public void testLambdaExpression17() { doParserTest("(String s -> s"); }
|
||||
public void testLambdaExpression18() { doParserTest("(java.lang.String s, -> s"); }
|
||||
public void testLambdaExpression19() { doParserTest("(@A T t) -> (null)"); }
|
||||
|
||||
public void testAmbiguousLambdaExpression() { doParserTest("f( (x) < y , z > (w) -> v )"); }
|
||||
|
||||
private void doParserTest(@NonNls final String text) {
|
||||
doParserTest(text, new MyTestParser());
|
||||
|
||||
@@ -275,6 +275,10 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
public void testPreserveDiamondOccurrences() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
public void testSubstituteTypeParams() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface JpsElement {
|
||||
|
||||
interface BulkModificationSupport<E extends JpsElement> extends JpsElement {
|
||||
@NotNull
|
||||
E createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
E createCopy();
|
||||
|
||||
void applyChanges(@NotNull E modified);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ public interface JpsElementCollection<E extends JpsElement> extends JpsParentEle
|
||||
List<E> getElements();
|
||||
|
||||
@NotNull
|
||||
<P> E addChild(@NotNull JpsElementFactoryWithParameter<E,P> factory, @NotNull P param);
|
||||
<P> E addChild(@NotNull JpsElementParameterizedCreator<E,P> factory, @NotNull P param);
|
||||
|
||||
@NotNull
|
||||
E addChild(@NotNull JpsElementFactory<E> factory);
|
||||
E addChild(@NotNull JpsElementCreator<E> creator);
|
||||
|
||||
E addChild(E element);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ public interface JpsElementContainer {
|
||||
T getChild(@NotNull JpsElementKind<T> kind);
|
||||
|
||||
@NotNull
|
||||
<T extends JpsElement, K extends JpsElementKind<T>&JpsElementFactory<T>>
|
||||
<T extends JpsElement, K extends JpsElementKind<T>&JpsElementCreator<T>>
|
||||
T setChild(@NotNull K kind);
|
||||
|
||||
@NotNull
|
||||
<T extends JpsElement, P, K extends JpsElementKind<T>&JpsElementFactoryWithParameter<T, P>>
|
||||
<T extends JpsElement, P, K extends JpsElementKind<T>&JpsElementParameterizedCreator<T, P>>
|
||||
T setChild(@NotNull K kind, @NotNull P param);
|
||||
|
||||
<T extends JpsElement>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementCreator<E extends JpsElement> {
|
||||
@NotNull
|
||||
E create();
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementFactory<E extends JpsElement> {
|
||||
public abstract class JpsElementFactory {
|
||||
public static JpsElementFactory getInstance() {
|
||||
return JpsServiceManager.getInstance().getService(JpsElementFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
E create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
public abstract JpsModuleReference createModuleReference(@NotNull String moduleName);
|
||||
|
||||
@NotNull
|
||||
public abstract JpsLibraryReference createLibraryReference(@NotNull String libraryName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementFactoryWithParameter<E extends JpsElement, P> {
|
||||
@NotNull
|
||||
E create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent, @NotNull P param);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementKind<E extends JpsElement> {
|
||||
|
||||
public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull E element) {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementParameterizedCreator<E extends JpsElement, P> {
|
||||
@NotNull
|
||||
E create(@NotNull P param);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -8,4 +9,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface JpsElementReference<T extends JpsElement> extends JpsElement {
|
||||
@Nullable
|
||||
T resolve();
|
||||
|
||||
JpsElementReference<T> asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,7 @@ public interface JpsModel {
|
||||
@NotNull
|
||||
JpsModel createModifiableModel(@NotNull JpsEventDispatcher eventDispatcher);
|
||||
|
||||
void registerExternalReference(@NotNull JpsElementReference<?> reference);
|
||||
|
||||
void commit();
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public interface JpsReferenceableElement<E extends JpsElement> {
|
||||
@NotNull
|
||||
JpsElementReference<E> createReference(JpsParentElement parent);
|
||||
JpsElementReference<E> createReference();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsNamedElement;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.JpsReferenceableElement;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,5 +21,5 @@ public interface JpsLibrary extends JpsNamedElement, JpsReferenceableElement<Jps
|
||||
void delete();
|
||||
|
||||
@NotNull
|
||||
JpsLibraryReference createReference(JpsParentElement parent);
|
||||
JpsLibraryReference createReference();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -9,4 +10,7 @@ import org.jetbrains.jps.model.JpsElementReference;
|
||||
public interface JpsLibraryReference extends JpsElementReference<JpsLibrary> {
|
||||
@NotNull
|
||||
String getLibraryName();
|
||||
|
||||
@Override
|
||||
JpsLibraryReference asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jps.model.module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,9 +15,15 @@ public interface JpsDependenciesList extends JpsElement {
|
||||
@NotNull
|
||||
JpsModuleDependency addModuleDependency(@NotNull JpsModule module);
|
||||
|
||||
@NotNull
|
||||
JpsModuleDependency addModuleDependency(@NotNull JpsModuleReference moduleReference);
|
||||
|
||||
@NotNull
|
||||
JpsLibraryDependency addLibraryDependency(@NotNull JpsLibrary libraryElement);
|
||||
|
||||
@NotNull
|
||||
JpsLibraryDependency addLibraryDependency(@NotNull JpsLibraryReference libraryReference);
|
||||
|
||||
void addModuleSourceDependency();
|
||||
|
||||
void addSdkDependency(@NotNull JpsSdkType<?> sdkType);
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,7 +37,10 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement<JpsM
|
||||
JpsElementContainer getContainer();
|
||||
|
||||
@NotNull
|
||||
JpsModuleReference createReference(JpsParentElement parent);
|
||||
JpsModuleReference createReference();
|
||||
|
||||
@NotNull
|
||||
JpsLibrary addModuleLibrary(@NotNull JpsLibraryType<?> type, @NotNull String name);
|
||||
|
||||
void delete();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -9,4 +10,7 @@ import org.jetbrains.jps.model.JpsElementReference;
|
||||
public interface JpsModuleReference extends JpsElementReference<JpsModule> {
|
||||
@NotNull
|
||||
String getModuleName();
|
||||
|
||||
@Override
|
||||
JpsModuleReference asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.jetbrains.jps.model.module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
|
||||
@@ -14,5 +13,5 @@ public interface JpsSdkReferencesTable extends JpsCompositeElement {
|
||||
@Nullable
|
||||
JpsLibraryReference getSdkReference(@NotNull JpsSdkType<?> type);
|
||||
|
||||
void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibrary sdk);
|
||||
void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibraryReference sdkReference);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.jetbrains.jps.service;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsServiceManager {
|
||||
public static JpsServiceManager getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public abstract <T> T getService(Class<T> serviceClass);
|
||||
|
||||
private static class InstanceHolder {
|
||||
private static final JpsServiceManager INSTANCE;
|
||||
static {
|
||||
INSTANCE = ServiceLoader.load(JpsServiceManager.class).iterator().next();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.model.impl.JpsElementFactoryImpl
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.service.impl.JpsServiceManagerImpl
|
||||
@@ -8,19 +8,13 @@ import org.jetbrains.jps.model.*;
|
||||
*/
|
||||
public abstract class JpsCompositeElementBase<Self extends JpsCompositeElementBase<Self>> extends JpsElementBase<Self> implements JpsCompositeElement {
|
||||
protected final JpsElementContainerImpl myContainer;
|
||||
protected final JpsModel myModel;
|
||||
|
||||
protected JpsCompositeElementBase(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
myContainer = new JpsElementContainerImpl(model, eventDispatcher, this);
|
||||
protected JpsCompositeElementBase() {
|
||||
myContainer = new JpsElementContainerImpl(this);
|
||||
}
|
||||
|
||||
protected JpsCompositeElementBase(JpsCompositeElementBase<Self> original, JpsModel model, JpsEventDispatcher dispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
myModel = model;
|
||||
myContainer = new JpsElementContainerImpl(original.myContainer, model, dispatcher, this);
|
||||
protected JpsCompositeElementBase(JpsCompositeElementBase<Self> original) {
|
||||
myContainer = new JpsElementContainerImpl(original.myContainer, this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull Self element) {
|
||||
|
||||
@@ -1,27 +1,52 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsElementBase<Self extends JpsElementBase<Self>> implements JpsElement, JpsElement.BulkModificationSupport<Self> {
|
||||
private JpsEventDispatcher myEventDispatcher;
|
||||
protected JpsParentElement myParent;
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.model.impl.JpsElementBase");
|
||||
protected JpsElementBase myParent;
|
||||
|
||||
protected JpsElementBase(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
protected JpsElementBase() {
|
||||
}
|
||||
|
||||
public void setParent(@Nullable JpsElementBase<?> parent) {
|
||||
if (myParent != null && parent != null) {
|
||||
LOG.error("Parent for " + this + " is already set");
|
||||
}
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
public JpsElementBase(JpsElementBase original, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myParent = parent;
|
||||
protected void fireElementChanged() {
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void setParent(@NotNull JpsElement element, @Nullable JpsElementBase<?> parent) {
|
||||
((JpsElementBase<?>)element).setParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JpsEventDispatcher getEventDispatcher() {
|
||||
return myEventDispatcher;
|
||||
if (myParent != null) {
|
||||
return myParent.getEventDispatcher();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JpsModel getModel() {
|
||||
if (myParent != null) {
|
||||
return myParent.getModel();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -31,11 +56,11 @@ public abstract class JpsElementBase<Self extends JpsElementBase<Self>> implemen
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract Self createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
public abstract Self createCopy();
|
||||
|
||||
public abstract void applyChanges(@NotNull Self modified);
|
||||
|
||||
public JpsParentElement getParent() {
|
||||
public JpsElementBase getParent() {
|
||||
return myParent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,30 +11,23 @@ import java.util.*;
|
||||
*/
|
||||
public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBase<JpsElementCollectionImpl<E>> implements JpsElementCollection<E> {
|
||||
private final List<E> myElements;
|
||||
private final JpsModel myModel;
|
||||
private final Map<E, E> myCopyToOriginal;
|
||||
private final JpsElementKind<E> myKind;
|
||||
|
||||
public JpsElementCollectionImpl(JpsElementKind<E> kind, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl(JpsElementKind<E> kind) {
|
||||
myKind = kind;
|
||||
myModel = model;
|
||||
myElements = new SmartList<E>();
|
||||
myCopyToOriginal = null;
|
||||
}
|
||||
|
||||
public JpsElementCollectionImpl(JpsElementCollectionImpl<E> original,
|
||||
JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl(JpsElementCollectionImpl<E> original) {
|
||||
myKind = original.myKind;
|
||||
myModel = model;
|
||||
myElements = new SmartList<E>();
|
||||
myCopyToOriginal = new HashMap<E, E>();
|
||||
for (E e : original.myElements) {
|
||||
//noinspection unchecked
|
||||
final E copy = (E)e.getBulkModificationSupport().createCopy(model, eventDispatcher, parent);
|
||||
final E copy = (E)e.getBulkModificationSupport().createCopy();
|
||||
setParent(copy, this);
|
||||
myElements.add(copy);
|
||||
myCopyToOriginal.put(copy, e);
|
||||
}
|
||||
@@ -47,20 +40,24 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <P> E addChild(@NotNull JpsElementFactoryWithParameter<E, P> factory, @NotNull P param) {
|
||||
return addChild(factory.create(myModel, getEventDispatcher(), myParent, param));
|
||||
public <P> E addChild(@NotNull JpsElementParameterizedCreator<E, P> factory, @NotNull P param) {
|
||||
return addChild(factory.create(param));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public E addChild(@NotNull JpsElementFactory<E> factory) {
|
||||
return addChild(factory.create(myModel, getEventDispatcher(), myParent));
|
||||
public E addChild(@NotNull JpsElementCreator<E> creator) {
|
||||
return addChild(creator.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
public E addChild(E element) {
|
||||
myElements.add(element);
|
||||
getEventDispatcher().fireElementAdded(element, myKind);
|
||||
setParent(element, this);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementAdded(element, myKind);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -68,16 +65,18 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
public void removeChild(@NotNull E element) {
|
||||
final boolean removed = myElements.remove(element);
|
||||
if (removed) {
|
||||
getEventDispatcher().fireElementRemoved(element, myKind);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRemoved(element, myKind);
|
||||
}
|
||||
setParent(element, null);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementCollectionImpl<E> createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsElementCollectionImpl<E>(this, model, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl<E> createCopy() {
|
||||
return new JpsElementCollectionImpl<E>(this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsElementCollectionImpl<E> modified) {
|
||||
@@ -93,7 +92,7 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
final E copy = (E)element.getBulkModificationSupport().createCopy(myModel, getEventDispatcher(), myParent);
|
||||
final E copy = (E)element.getBulkModificationSupport().createCopy();
|
||||
toAdd.add(copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.jps.model.*;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementCollectionKind<E extends JpsElement> extends JpsElementKind<JpsElementCollectionImpl<E>>
|
||||
implements JpsElementFactory<JpsElementCollectionImpl<E>> {
|
||||
implements JpsElementCreator<JpsElementCollectionImpl<E>> {
|
||||
private final JpsElementKind<E> myElementKind;
|
||||
|
||||
public JpsElementCollectionKind(JpsElementKind<E> elementKind) {
|
||||
@@ -16,9 +16,7 @@ public class JpsElementCollectionKind<E extends JpsElement> extends JpsElementKi
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementCollectionImpl<E> create(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsElementCollectionImpl<E>(myElementKind, model, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl<E> create() {
|
||||
return new JpsElementCollectionImpl<E>(myElementKind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -11,25 +12,19 @@ import java.util.Map;
|
||||
*/
|
||||
public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
private final Map<JpsElementKind<?>, JpsElement> myElements = new HashMap<JpsElementKind<?>, JpsElement>();
|
||||
private final @NotNull JpsModel myModel;
|
||||
private final @NotNull JpsEventDispatcher myEventDispatcher;
|
||||
private final @NotNull JpsParentElement myParent;
|
||||
private final @NotNull JpsCompositeElementBase<?> myParent;
|
||||
|
||||
public JpsElementContainerImpl(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
public JpsElementContainerImpl(@NotNull JpsCompositeElementBase<?> parent) {
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
public JpsElementContainerImpl(@NotNull JpsElementContainerImpl original, @NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
public JpsElementContainerImpl(@NotNull JpsElementContainerImpl original, @NotNull JpsCompositeElementBase<?> parent) {
|
||||
myParent = parent;
|
||||
for (Map.Entry<JpsElementKind<?>, JpsElement> entry : original.myElements.entrySet()) {
|
||||
final JpsElementKind kind = entry.getKey();
|
||||
myElements.put(kind, entry.getValue().getBulkModificationSupport().createCopy(myModel, myEventDispatcher, myParent));
|
||||
final JpsElement copy = entry.getValue().getBulkModificationSupport().createCopy();
|
||||
JpsElementBase.setParent(copy, myParent);
|
||||
myElements.put(kind, copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,23 +36,27 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends JpsElement, P, K extends JpsElementKind<T> & JpsElementFactoryWithParameter<T, P>> T setChild(@NotNull K kind,
|
||||
public <T extends JpsElement, P, K extends JpsElementKind<T> & JpsElementParameterizedCreator<T, P>> T setChild(@NotNull K kind,
|
||||
@NotNull P param) {
|
||||
final T child = kind.create(myModel, myEventDispatcher, myParent, param);
|
||||
final T child = kind.create(param);
|
||||
return setChild(kind, child);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends JpsElement, K extends JpsElementKind<T> & JpsElementFactory<T>> T setChild(@NotNull K kind) {
|
||||
final T child = kind.create(myModel, myEventDispatcher, myParent);
|
||||
public <T extends JpsElement, K extends JpsElementKind<T> & JpsElementCreator<T>> T setChild(@NotNull K kind) {
|
||||
final T child = kind.create();
|
||||
return setChild(kind, child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends JpsElement> T setChild(JpsElementKind<T> kind, T child) {
|
||||
myElements.put(kind, child);
|
||||
myEventDispatcher.fireElementAdded(child, kind);
|
||||
JpsElementBase.setParent(child, myParent);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementAdded(child, kind);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -65,7 +64,11 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
public <T extends JpsElement> void removeChild(@NotNull JpsElementKind<T> kind) {
|
||||
//noinspection unchecked
|
||||
final T removed = (T)myElements.remove(kind);
|
||||
myEventDispatcher.fireElementRemoved(removed, kind);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRemoved(removed, kind);
|
||||
}
|
||||
JpsElementBase.setParent(removed, null);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsElementContainerImpl modified) {
|
||||
@@ -92,7 +95,12 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
setChild(kind, (T)modifiedChild.getBulkModificationSupport().createCopy(myModel, myEventDispatcher, myParent));
|
||||
setChild(kind, (T)modifiedChild.getBulkModificationSupport().createCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JpsEventDispatcher getEventDispatcher() {
|
||||
return myParent.getEventDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryReferenceImpl;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.model.module.impl.JpsModuleReferenceImpl;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementFactoryImpl extends JpsElementFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReference createModuleReference(@NotNull String moduleName) {
|
||||
return new JpsModuleReferenceImpl(moduleName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReference createLibraryReference(@NotNull String libraryName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
return new JpsLibraryReferenceImpl(libraryName, parentReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsElementReferenceBase<E extends JpsElementReferenceBase<E, T>, T extends JpsElement> extends JpsElementBase<E> implements JpsElementReference<T> {
|
||||
@Override
|
||||
public JpsElementReference<T> asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,17 @@ import org.jetbrains.jps.model.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsGlobalElementReference extends JpsElementBase<JpsGlobalElementReference> implements JpsElementReference<JpsGlobal> {
|
||||
private final JpsModel myModel;
|
||||
|
||||
public JpsGlobalElementReference(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
public class JpsGlobalElementReference extends JpsElementReferenceBase<JpsGlobalElementReference, JpsGlobal> {
|
||||
@Override
|
||||
public JpsGlobal resolve() {
|
||||
return myModel.getGlobal();
|
||||
final JpsModel model = getModel();
|
||||
return model != null ? model.getGlobal() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsGlobalElementReference createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsGlobalElementReference(model, eventDispatcher, parent);
|
||||
public JpsGlobalElementReference createCopy() {
|
||||
return new JpsGlobalElementReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,32 +10,26 @@ import org.jetbrains.jps.model.library.impl.JpsLibraryKind;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsGlobalImpl extends JpsCompositeElementBase<JpsGlobalImpl> implements JpsGlobal {
|
||||
public class JpsGlobalImpl extends JpsRootElementBase<JpsGlobalImpl> implements JpsGlobal {
|
||||
public JpsGlobalImpl(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(model, eventDispatcher, null);
|
||||
super(model, eventDispatcher);
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsGlobalImpl(JpsGlobalImpl original, JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(original, model, eventDispatcher, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsGlobalImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsGlobalImpl(this, model, eventDispatcher);
|
||||
super(original, model, eventDispatcher);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addLibrary(@NotNull JpsLibraryType libraryType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType, myModel, getEventDispatcher(), collection));
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementReference<JpsGlobal> createReference(JpsParentElement parent) {
|
||||
return new JpsGlobalElementReference(myModel, getEventDispatcher(), parent);
|
||||
public JpsElementReference<JpsGlobal> createReference() {
|
||||
return new JpsGlobalElementReference();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
@@ -11,14 +12,17 @@ public class JpsModelImpl implements JpsModel {
|
||||
private JpsProjectImpl myProject;
|
||||
private JpsGlobalImpl myGlobal;
|
||||
private JpsModelImpl myOriginalModel;
|
||||
private final JpsEventDispatcher myEventDispatcher;
|
||||
|
||||
public JpsModelImpl(JpsEventDispatcher eventDispatcher) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myProject = new JpsProjectImpl(this, eventDispatcher);
|
||||
myGlobal = new JpsGlobalImpl(this, eventDispatcher);
|
||||
}
|
||||
|
||||
private JpsModelImpl(JpsModelImpl original, JpsEventDispatcher eventDispatcher) {
|
||||
myOriginalModel = original;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myProject = new JpsProjectImpl(original.myProject, this, eventDispatcher);
|
||||
myGlobal = new JpsGlobalImpl(original.myGlobal, this, eventDispatcher);
|
||||
}
|
||||
@@ -39,6 +43,11 @@ public class JpsModelImpl implements JpsModel {
|
||||
return new JpsModelImpl(this, eventDispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerExternalReference(@NotNull JpsElementReference<?> reference) {
|
||||
myProject.addExternalReference(reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
myOriginalModel.applyChanges(this);
|
||||
|
||||
@@ -11,17 +11,13 @@ public abstract class JpsNamedCompositeElementBase<Self extends JpsNamedComposit
|
||||
implements JpsNamedElement {
|
||||
private String myName;
|
||||
|
||||
protected JpsNamedCompositeElementBase(JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher,
|
||||
@NotNull String name, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsNamedCompositeElementBase(@NotNull String name) {
|
||||
super();
|
||||
myName = name;
|
||||
}
|
||||
|
||||
protected JpsNamedCompositeElementBase(JpsNamedCompositeElementBase<Self, Parent> original,
|
||||
JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
protected JpsNamedCompositeElementBase(JpsNamedCompositeElementBase<Self, Parent> original) {
|
||||
super(original);
|
||||
myName = original.myName;
|
||||
}
|
||||
|
||||
@@ -41,7 +37,10 @@ public abstract class JpsNamedCompositeElementBase<Self extends JpsNamedComposit
|
||||
if (!myName.equals(name)) {
|
||||
String oldName = myName;
|
||||
myName = name;
|
||||
getEventDispatcher().fireElementRenamed(this, oldName, name);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRenamed(this, oldName, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,17 @@ public abstract class JpsNamedElementReferenceBase<T extends JpsNamedElement, Se
|
||||
private final JpsElementCollectionKind<? extends T> myCollectionKind;
|
||||
protected final String myElementName;
|
||||
|
||||
protected JpsNamedElementReferenceBase(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, @NotNull JpsElementCollectionKind<? extends T> kind, @NotNull String elementName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsNamedElementReferenceBase(@NotNull JpsElementCollectionKind<? extends T> kind,
|
||||
@NotNull String elementName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
super();
|
||||
myCollectionKind = kind;
|
||||
myElementName = elementName;
|
||||
myContainer.setChild(PARENT_REFERENCE_KIND, parentReference);
|
||||
}
|
||||
|
||||
protected JpsNamedElementReferenceBase(JpsNamedElementReferenceBase<T, Self> original,
|
||||
JpsModel model, JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
protected JpsNamedElementReferenceBase(JpsNamedElementReferenceBase<T, Self> original) {
|
||||
super(original);
|
||||
myCollectionKind = original.myCollectionKind;
|
||||
myElementName = original.myElementName;
|
||||
}
|
||||
|
||||
@@ -6,25 +6,17 @@ import org.jetbrains.jps.model.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsProjectElementReference extends JpsElementBase<JpsProjectElementReference> implements JpsElementReference<JpsProject> {
|
||||
private final JpsModel myModel;
|
||||
|
||||
public JpsProjectElementReference(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
public class JpsProjectElementReference extends JpsElementReferenceBase<JpsProjectElementReference, JpsProject> {
|
||||
@Override
|
||||
public JpsProject resolve() {
|
||||
return myModel.getProject();
|
||||
final JpsModel model = getModel();
|
||||
return model != null ? model.getProject() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsProjectElementReference createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsProjectElementReference(model, eventDispatcher, parent);
|
||||
public JpsProjectElementReference createCopy() {
|
||||
return new JpsProjectElementReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,29 +16,36 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsProjectImpl extends JpsCompositeElementBase<JpsProjectImpl> implements JpsProject {
|
||||
public class JpsProjectImpl extends JpsRootElementBase<JpsProjectImpl> implements JpsProject {
|
||||
private static final JpsElementCollectionKind<JpsElementReference<?>> EXTERNAL_REFERENCES_COLLECTION_KIND = new JpsElementCollectionKind<JpsElementReference<?>>(new JpsElementKind<JpsElementReference<?>>());
|
||||
|
||||
public JpsProjectImpl(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(model, eventDispatcher, null);
|
||||
super(model, eventDispatcher);
|
||||
myContainer.setChild(JpsModuleKind.MODULE_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
myContainer.setChild(EXTERNAL_REFERENCES_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsProjectImpl(JpsProjectImpl original, JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(original, model, eventDispatcher, null);
|
||||
super(original, model, eventDispatcher);
|
||||
}
|
||||
|
||||
public void addExternalReference(@NotNull JpsElementReference<?> reference) {
|
||||
myContainer.getChild(EXTERNAL_REFERENCES_COLLECTION_KIND).addChild(reference);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModule addModule(@NotNull JpsModuleType<?> moduleType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsModuleImpl> collection = myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsModuleImpl(myModel, getEventDispatcher(), moduleType, name, collection));
|
||||
return collection.addChild(new JpsModuleImpl(moduleType, name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addLibrary(@NotNull JpsLibraryType<?> libraryType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType, myModel, getEventDispatcher(), collection));
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -55,13 +62,7 @@ public class JpsProjectImpl extends JpsCompositeElementBase<JpsProjectImpl> impl
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementReference<JpsProject> createReference(JpsParentElement parent) {
|
||||
return new JpsProjectElementReference(myModel, getEventDispatcher(), parent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsProjectImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsProjectImpl(this, model, eventDispatcher);
|
||||
public JpsElementReference<JpsProject> createReference() {
|
||||
return new JpsProjectElementReference();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsRootElementBase<E extends JpsRootElementBase<E>> extends JpsCompositeElementBase<E> {
|
||||
private final JpsModel myModel;
|
||||
private final JpsEventDispatcher myEventDispatcher;
|
||||
|
||||
protected JpsRootElementBase(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super();
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
protected JpsRootElementBase(JpsCompositeElementBase<E> original, JpsModel model, JpsEventDispatcher dispatcher) {
|
||||
super(original);
|
||||
myModel = model;
|
||||
myEventDispatcher = dispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JpsEventDispatcher getEventDispatcher() {
|
||||
return myEventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JpsModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public E createCopy() {
|
||||
throw new UnsupportedOperationException("'createCopy' not implemented in " + getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,12 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
private final T myType;
|
||||
private JpsElementProperties myProperties;
|
||||
|
||||
public JpsTypedDataImpl(T type, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsTypedDataImpl(T type) {
|
||||
myType = type;
|
||||
myProperties = type.createDefaultProperties();
|
||||
}
|
||||
|
||||
public JpsTypedDataImpl(JpsTypedDataImpl<T> original,
|
||||
JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsTypedDataImpl(JpsTypedDataImpl<T> original) {
|
||||
myType = original.getType();
|
||||
final JpsElementType<?> type = original.getType();
|
||||
myProperties = createCopy(type, original.myProperties);
|
||||
@@ -44,8 +41,8 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsTypedDataImpl<T> createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsTypedDataImpl<T>(this, eventDispatcher, parent);
|
||||
public JpsTypedDataImpl<T> createCopy() {
|
||||
return new JpsTypedDataImpl<T>(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -56,7 +53,7 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
public void setProperties(@NotNull JpsElementProperties properties) {
|
||||
if (!myProperties.equals(properties)) {
|
||||
myProperties = properties;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,17 @@ import java.util.List;
|
||||
public class JpsUrlListImpl extends JpsElementBase<JpsUrlListImpl> implements JpsUrlList {
|
||||
private List<String> myUrls = new ArrayList<String>();
|
||||
|
||||
public JpsUrlListImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsUrlListImpl() {
|
||||
}
|
||||
|
||||
public JpsUrlListImpl(JpsUrlListImpl list, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(list, dispatcher, parent);
|
||||
public JpsUrlListImpl(JpsUrlListImpl list) {
|
||||
myUrls.addAll(list.myUrls);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsUrlListImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsUrlListImpl(this, eventDispatcher, parent);
|
||||
public JpsUrlListImpl createCopy() {
|
||||
return new JpsUrlListImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -36,20 +34,20 @@ public class JpsUrlListImpl extends JpsElementBase<JpsUrlListImpl> implements Jp
|
||||
@Override
|
||||
public void addUrl(@NotNull String url) {
|
||||
myUrls.add(url);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUrl(@NotNull String url) {
|
||||
myUrls.remove(url);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsUrlListImpl modified) {
|
||||
if (!myUrls.equals(modified.myUrls)) {
|
||||
myUrls.clear();
|
||||
myUrls.addAll(modified.myUrls);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@ import org.jetbrains.jps.model.*;
|
||||
public class SimpleJpsElementImpl<P extends JpsElementProperties> extends JpsElementBase<SimpleJpsElementImpl<P>> implements SimpleJpsElement<P> {
|
||||
private P myProperties;
|
||||
|
||||
public SimpleJpsElementImpl(JpsEventDispatcher eventDispatcher, P properties, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public SimpleJpsElementImpl(P properties) {
|
||||
myProperties = properties;
|
||||
}
|
||||
|
||||
public SimpleJpsElementImpl(SimpleJpsElementImpl<P> original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public SimpleJpsElementImpl(SimpleJpsElementImpl<P> original) {
|
||||
myProperties = original.myProperties;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -28,14 +27,14 @@ public class SimpleJpsElementImpl<P extends JpsElementProperties> extends JpsEle
|
||||
public void setProperties(@NotNull P properties) {
|
||||
if (!myProperties.equals(properties)) {
|
||||
myProperties = properties;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleJpsElementImpl<P> createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new SimpleJpsElementImpl<P>(this, eventDispatcher, parent);
|
||||
public SimpleJpsElementImpl<P> createCopy() {
|
||||
return new SimpleJpsElementImpl<P>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,6 @@ package org.jetbrains.jps.model.java.impl;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.java.JavaModuleExtension;
|
||||
import org.jetbrains.jps.model.java.LanguageLevel;
|
||||
@@ -17,12 +14,10 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
private String myTestOutputUrl;
|
||||
private LanguageLevel myLanguageLevel;
|
||||
|
||||
public JavaModuleExtensionImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl() {
|
||||
}
|
||||
|
||||
public JavaModuleExtensionImpl(JavaModuleExtensionImpl original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public JavaModuleExtensionImpl(JavaModuleExtensionImpl original) {
|
||||
myOutputUrl = original.myOutputUrl;
|
||||
myTestOutputUrl = original.myTestOutputUrl;
|
||||
myLanguageLevel = original.myLanguageLevel;
|
||||
@@ -30,8 +25,8 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaModuleExtensionImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JavaModuleExtensionImpl(this, eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl createCopy() {
|
||||
return new JavaModuleExtensionImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +38,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setOutputUrl(String outputUrl) {
|
||||
if (!Comparing.equal(myOutputUrl, outputUrl)) {
|
||||
myOutputUrl = outputUrl;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +51,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setTestOutputUrl(String testOutputUrl) {
|
||||
if (!Comparing.equal(myTestOutputUrl, testOutputUrl)) {
|
||||
myTestOutputUrl = testOutputUrl;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +64,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setLanguageLevel(LanguageLevel languageLevel) {
|
||||
if (!Comparing.equal(myLanguageLevel, languageLevel)) {
|
||||
myLanguageLevel = languageLevel;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaModuleExtensionKind extends JpsElementKind<JavaModuleExtensionImpl> implements JpsElementFactory<JavaModuleExtensionImpl> {
|
||||
public class JavaModuleExtensionKind extends JpsElementKind<JavaModuleExtensionImpl> implements JpsElementCreator<JavaModuleExtensionImpl> {
|
||||
private static final JavaModuleExtensionKind INSTANCE = new JavaModuleExtensionKind();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaModuleExtensionImpl create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JavaModuleExtensionImpl(eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl create() {
|
||||
return new JavaModuleExtensionImpl();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-13
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.model.java.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyExtension;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyScope;
|
||||
@@ -15,14 +12,13 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
private boolean myExported;
|
||||
private JpsJavaDependencyScope myScope;
|
||||
|
||||
public JpsJavaDependencyExtensionImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent, boolean exported, JpsJavaDependencyScope scope) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl(boolean exported,
|
||||
JpsJavaDependencyScope scope) {
|
||||
myExported = exported;
|
||||
myScope = scope;
|
||||
}
|
||||
|
||||
public JpsJavaDependencyExtensionImpl(JpsJavaDependencyExtensionImpl original, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl(JpsJavaDependencyExtensionImpl original) {
|
||||
myExported = original.myExported;
|
||||
myScope = original.myScope;
|
||||
}
|
||||
@@ -36,7 +32,7 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
public void setExported(boolean exported) {
|
||||
if (myExported != exported) {
|
||||
myExported = exported;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +46,14 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
public void setScope(@NotNull JpsJavaDependencyScope scope) {
|
||||
if (!scope.equals(myScope)) {
|
||||
myScope = scope;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsJavaDependencyExtensionImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsJavaDependencyExtensionImpl(this, eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl createCopy() {
|
||||
return new JpsJavaDependencyExtensionImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -9,16 +9,13 @@ import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsJavaDependencyExtensionKind extends JpsElementKind<JpsJavaDependencyExtensionImpl>
|
||||
implements JpsElementFactory<JpsJavaDependencyExtensionImpl> {
|
||||
public class JpsJavaDependencyExtensionKind extends JpsElementKind<JpsJavaDependencyExtensionImpl> implements JpsElementCreator<JpsJavaDependencyExtensionImpl> {
|
||||
public static final JpsJavaDependencyExtensionKind INSTANCE = new JpsJavaDependencyExtensionKind();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsJavaDependencyExtensionImpl create(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsJavaDependencyExtensionImpl(eventDispatcher, parent, false, JpsJavaDependencyScope.COMPILE);
|
||||
public JpsJavaDependencyExtensionImpl create() {
|
||||
return new JpsJavaDependencyExtensionImpl(false, JpsJavaDependencyScope.COMPILE);
|
||||
}
|
||||
|
||||
public static JpsJavaDependencyExtension getExtension(@NotNull JpsDependencyElement element) {
|
||||
|
||||
@@ -18,15 +18,14 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
private static final JpsElementCollectionKind<JpsLibraryRootImpl> LIBRARY_ROOTS_COLLECTION = new JpsElementCollectionKind<JpsLibraryRootImpl>(JpsLibraryRootKind.INSTANCE);
|
||||
private static final JpsTypedDataKind<JpsLibraryType<?>> TYPED_DATA_KIND = new JpsTypedDataKind<JpsLibraryType<?>>();
|
||||
|
||||
public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType<?> type, @NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsElementCollection<JpsLibraryImpl> parent) {
|
||||
super(model, eventDispatcher, name, parent);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsLibraryType<?>>(type, eventDispatcher, this));
|
||||
public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType<?> type) {
|
||||
super(name);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsLibraryType<?>>(type));
|
||||
myContainer.setChild(LIBRARY_ROOTS_COLLECTION);
|
||||
}
|
||||
|
||||
public JpsLibraryImpl(@NotNull JpsLibraryImpl original, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsLibraryImpl(@NotNull JpsLibraryImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -43,7 +42,7 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
|
||||
@Override
|
||||
public void addUrl(@NotNull final String url, @NotNull final JpsLibraryRootType rootType) {
|
||||
getRootsCollection().addChild(new JpsLibraryRootImpl(getEventDispatcher(), url, rootType, this));
|
||||
getRootsCollection().addChild(new JpsLibraryRootImpl(url, rootType));
|
||||
}
|
||||
|
||||
private JpsElementCollectionImpl<JpsLibraryRootImpl> getRootsCollection() {
|
||||
@@ -73,15 +72,15 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsLibraryImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryImpl createCopy() {
|
||||
return new JpsLibraryImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReference createReference(JpsParentElement parent) {
|
||||
public JpsLibraryReference createReference() {
|
||||
//noinspection unchecked
|
||||
final JpsElementReference<JpsCompositeElement> parentReference = ((JpsReferenceableElement<JpsCompositeElement>)getParent().getParent()).createReference(parent);
|
||||
return new JpsLibraryReferenceImpl(myModel, getEventDispatcher(), getName(), parentReference, parent);
|
||||
final JpsElementReference<JpsCompositeElement> parentReference = ((JpsReferenceableElement<JpsCompositeElement>)getParent().getParent()).createReference();
|
||||
return new JpsLibraryReferenceImpl(getName(), parentReference);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -10,13 +10,12 @@ import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsLibraryReferenceImpl extends JpsNamedElementReferenceBase<JpsLibrary, JpsLibraryReferenceImpl> implements JpsLibraryReference {
|
||||
public JpsLibraryReferenceImpl(JpsModel model, JpsEventDispatcher eventDispatcher, String elementName, JpsElementReference<? extends JpsCompositeElement> parentReference,
|
||||
JpsParentElement parent) {
|
||||
super(model, eventDispatcher, JpsLibraryKind.LIBRARIES_COLLECTION_KIND, elementName, parentReference, parent);
|
||||
public JpsLibraryReferenceImpl(String elementName, JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
super(JpsLibraryKind.LIBRARIES_COLLECTION_KIND, elementName, parentReference);
|
||||
}
|
||||
|
||||
public JpsLibraryReferenceImpl(JpsLibraryReferenceImpl original, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsLibraryReferenceImpl(JpsLibraryReferenceImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -27,9 +26,13 @@ public class JpsLibraryReferenceImpl extends JpsNamedElementReferenceBase<JpsLib
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReferenceImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsLibraryReferenceImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryReferenceImpl createCopy() {
|
||||
return new JpsLibraryReferenceImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsLibraryReference asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.model.library.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryRoot;
|
||||
@@ -16,14 +13,13 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
private final String myUrl;
|
||||
private final JpsLibraryRootType myRootType;
|
||||
|
||||
public JpsLibraryRootImpl(JpsEventDispatcher eventDispatcher, @NotNull String url, @NotNull JpsLibraryRootType rootType, @NotNull JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsLibraryRootImpl(@NotNull String url,
|
||||
@NotNull JpsLibraryRootType rootType) {
|
||||
myUrl = url;
|
||||
myRootType = rootType;
|
||||
}
|
||||
|
||||
public JpsLibraryRootImpl(JpsLibraryRootImpl original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public JpsLibraryRootImpl(JpsLibraryRootImpl original) {
|
||||
myUrl = original.myUrl;
|
||||
myRootType = original.myRootType;
|
||||
}
|
||||
@@ -41,8 +37,8 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryRootImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsLibraryRootImpl(this, eventDispatcher, parent);
|
||||
public JpsLibraryRootImpl createCopy() {
|
||||
return new JpsLibraryRootImpl(this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsLibraryRootImpl modified) {
|
||||
@@ -51,6 +47,6 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsLibrary getLibrary() {
|
||||
return (JpsLibrary)myParent;
|
||||
return (JpsLibrary)myParent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
+23
-13
@@ -2,12 +2,10 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementKind;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.impl.JpsElementCollectionKind;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
|
||||
@@ -20,13 +18,13 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
public static final JpsElementKind<JpsDependencyElementBase<?>> DEPENDENCY_ELEMENT_KIND = new JpsElementKind<JpsDependencyElementBase<?>>();
|
||||
public static final JpsElementCollectionKind<JpsDependencyElementBase<?>> DEPENDENCY_COLLECTION_KIND = new JpsElementCollectionKind<JpsDependencyElementBase<?>>(DEPENDENCY_ELEMENT_KIND);
|
||||
|
||||
public JpsDependenciesListImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModuleImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
public JpsDependenciesListImpl() {
|
||||
super();
|
||||
myContainer.setChild(DEPENDENCY_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsDependenciesListImpl(JpsDependenciesListImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
private JpsDependenciesListImpl(JpsDependenciesListImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +36,13 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsModuleDependency addModuleDependency(@NotNull JpsModule module) {
|
||||
final JpsModuleDependencyImpl dependency = new JpsModuleDependencyImpl(myModel, getEventDispatcher(), module, this);
|
||||
return addModuleDependency(module.createReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleDependency addModuleDependency(@NotNull JpsModuleReference moduleReference) {
|
||||
final JpsModuleDependencyImpl dependency = new JpsModuleDependencyImpl(moduleReference);
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(dependency);
|
||||
return dependency;
|
||||
}
|
||||
@@ -46,25 +50,31 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsLibraryDependency addLibraryDependency(@NotNull JpsLibrary libraryElement) {
|
||||
JpsLibraryDependencyImpl dependency = new JpsLibraryDependencyImpl(myModel, getEventDispatcher(), libraryElement, this);
|
||||
return addLibraryDependency(libraryElement.createReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryDependency addLibraryDependency(@NotNull JpsLibraryReference libraryReference) {
|
||||
final JpsLibraryDependencyImpl dependency = new JpsLibraryDependencyImpl(libraryReference);
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(dependency);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModuleSourceDependency() {
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsModuleSourceDependency(myModel, getEventDispatcher(), this));
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsModuleSourceDependency());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSdkDependency(@NotNull JpsSdkType<?> sdkType) {
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsSdkDependencyImpl(sdkType, myModel, getEventDispatcher(), this));
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsSdkDependencyImpl(sdkType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsDependenciesListImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsDependenciesListImpl(this, model, eventDispatcher, parent);
|
||||
public JpsDependenciesListImpl createCopy() {
|
||||
return new JpsDependenciesListImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-8
@@ -1,8 +1,5 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
|
||||
@@ -10,16 +7,16 @@ import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsDependencyElementBase<Self extends JpsDependencyElementBase<Self>> extends JpsCompositeElementBase<Self> implements JpsDependencyElement {
|
||||
protected JpsDependencyElementBase(JpsModel model, JpsEventDispatcher eventDispatcher, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsDependencyElementBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected JpsDependencyElementBase(JpsDependencyElementBase<Self> original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
protected JpsDependencyElementBase(JpsDependencyElementBase<Self> original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
((JpsDependenciesListImpl)myParent).getContainer().getChild(JpsDependenciesListImpl.DEPENDENCY_COLLECTION_KIND).removeChild(this);
|
||||
((JpsDependenciesListImpl)myParent.getParent()).getContainer().getChild(JpsDependenciesListImpl.DEPENDENCY_COLLECTION_KIND).removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.module.JpsLibraryDependency;
|
||||
|
||||
@@ -12,13 +11,13 @@ import org.jetbrains.jps.model.module.JpsLibraryDependency;
|
||||
public class JpsLibraryDependencyImpl extends JpsDependencyElementBase<JpsLibraryDependencyImpl> implements JpsLibraryDependency {
|
||||
public static final JpsElementKind<JpsLibraryReference> LIBRARY_REFERENCE_KIND = new JpsElementKind<JpsLibraryReference>();
|
||||
|
||||
public JpsLibraryDependencyImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsLibrary library, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
myContainer.setChild(LIBRARY_REFERENCE_KIND, library.createReference(parent));
|
||||
public JpsLibraryDependencyImpl(final JpsLibraryReference reference) {
|
||||
super();
|
||||
myContainer.setChild(LIBRARY_REFERENCE_KIND, reference);
|
||||
}
|
||||
|
||||
public JpsLibraryDependencyImpl(JpsLibraryDependencyImpl original, @NotNull JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsLibraryDependencyImpl(JpsLibraryDependencyImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -29,9 +28,7 @@ public class JpsLibraryDependencyImpl extends JpsDependencyElementBase<JpsLibrar
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryDependencyImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsLibraryDependencyImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryDependencyImpl createCopy() {
|
||||
return new JpsLibraryDependencyImpl(this);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleDependency;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
|
||||
@@ -12,13 +11,13 @@ import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleDependencyImpl> implements JpsModuleDependency {
|
||||
private static final JpsElementKind<JpsModuleReference> MODULE_REFERENCE_KIND = new JpsElementKind<JpsModuleReference>();
|
||||
|
||||
public JpsModuleDependencyImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModule module, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
myContainer.setChild(MODULE_REFERENCE_KIND, module.createReference(this));
|
||||
public JpsModuleDependencyImpl(final JpsModuleReference moduleReference) {
|
||||
super();
|
||||
myContainer.setChild(MODULE_REFERENCE_KIND, moduleReference);
|
||||
}
|
||||
|
||||
public JpsModuleDependencyImpl(JpsModuleDependencyImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsModuleDependencyImpl(JpsModuleDependencyImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -29,9 +28,7 @@ public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleD
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleDependencyImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsModuleDependencyImpl(this, model, eventDispatcher, parent);
|
||||
public JpsModuleDependencyImpl createCopy() {
|
||||
return new JpsModuleDependencyImpl(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package org.jetbrains.jps.model.module.impl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.impl.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryType;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryImpl;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryKind;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,24 +20,26 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
private static final JpsElementKind<JpsUrlListImpl> EXCLUDED_ROOTS_KIND = new JpsElementKind<JpsUrlListImpl>();
|
||||
public static final JpsElementKind<JpsDependenciesListImpl> DEPENDENCIES_LIST_KIND = new JpsElementKind<JpsDependenciesListImpl>();
|
||||
|
||||
public JpsModuleImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModuleType type, @NotNull String name, JpsElementCollectionImpl<JpsModuleImpl> parent) {
|
||||
super(model, eventDispatcher, name, parent);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleType<?>>(type, eventDispatcher, this));
|
||||
myContainer.setChild(CONTENT_ROOTS_KIND, new JpsUrlListImpl(eventDispatcher, this));
|
||||
myContainer.setChild(EXCLUDED_ROOTS_KIND, new JpsUrlListImpl(eventDispatcher, this));
|
||||
myContainer.setChild(DEPENDENCIES_LIST_KIND, new JpsDependenciesListImpl(model, eventDispatcher, this));
|
||||
public JpsModuleImpl(JpsModuleType type,
|
||||
@NotNull String name) {
|
||||
super(name);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleType<?>>(type));
|
||||
myContainer.setChild(CONTENT_ROOTS_KIND, new JpsUrlListImpl());
|
||||
myContainer.setChild(EXCLUDED_ROOTS_KIND, new JpsUrlListImpl());
|
||||
myContainer.setChild(DEPENDENCIES_LIST_KIND, new JpsDependenciesListImpl());
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsModuleSourceRootKind.ROOT_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsSdkReferencesTableImpl.KIND, new JpsSdkReferencesTableImpl(model, eventDispatcher, this));
|
||||
myContainer.setChild(JpsSdkReferencesTableImpl.KIND, new JpsSdkReferencesTableImpl());
|
||||
}
|
||||
|
||||
public JpsModuleImpl(JpsModuleImpl original, JpsEventDispatcher eventDispatcher, JpsModel model, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsModuleImpl(JpsModuleImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsModuleImpl(this, eventDispatcher, model, parent);
|
||||
public JpsModuleImpl createCopy() {
|
||||
return new JpsModuleImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -65,7 +71,7 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
public <P extends JpsElementProperties> JpsModuleSourceRoot addSourceRoot(@NotNull JpsModuleSourceRootType<P> rootType,
|
||||
@NotNull String url,
|
||||
@NotNull P properties) {
|
||||
final JpsModuleSourceRootImpl root = new JpsModuleSourceRootImpl(myModel, getEventDispatcher(), url, rootType, this);
|
||||
final JpsModuleSourceRootImpl root = new JpsModuleSourceRootImpl(url, rootType);
|
||||
myContainer.getChild(JpsModuleSourceRootKind.ROOT_COLLECTION_KIND).addChild(root);
|
||||
root.setProperties(rootType, properties);
|
||||
return root;
|
||||
@@ -102,7 +108,14 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReference createReference(JpsParentElement parent) {
|
||||
return new JpsModuleReferenceImpl(myModel, getName(), getEventDispatcher(), parent);
|
||||
public JpsModuleReference createReference() {
|
||||
return new JpsModuleReferenceImpl(getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addModuleLibrary(@NotNull JpsLibraryType<?> type, @NotNull String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsNamedElementReferenceBase;
|
||||
import org.jetbrains.jps.model.impl.JpsProjectElementReference;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
@@ -14,16 +11,14 @@ import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsModuleReferenceImpl extends JpsNamedElementReferenceBase<JpsModule, JpsModuleReferenceImpl> implements JpsModuleReference {
|
||||
public JpsModuleReferenceImpl(JpsModel model, String elementName, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, JpsModuleKind.MODULE_COLLECTION_KIND, elementName, new JpsProjectElementReference(model, eventDispatcher, parent), parent);
|
||||
public JpsModuleReferenceImpl(String elementName) {
|
||||
super(JpsModuleKind.MODULE_COLLECTION_KIND, elementName, new JpsProjectElementReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReferenceImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsModuleReferenceImpl(model, myElementName, eventDispatcher, parent);
|
||||
public JpsModuleReferenceImpl createCopy() {
|
||||
return new JpsModuleReferenceImpl(myElementName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -31,4 +26,10 @@ public class JpsModuleReferenceImpl extends JpsNamedElementReferenceBase<JpsModu
|
||||
public String getModuleName() {
|
||||
return myElementName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsModuleReference asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user