mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' into upsource-master
This commit is contained in:
@@ -496,8 +496,6 @@ def layout_core(String home, String target) {
|
||||
module("core-impl")
|
||||
module("boot")
|
||||
module("extensions")
|
||||
module("indexing-api")
|
||||
module("indexing-impl")
|
||||
module("java-psi-api")
|
||||
module("java-psi-impl")
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</properties>
|
||||
<border type="none" title-resource-bundle="org/intellij/images/ImagesBundle" title-key="main.page.border.title"/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<children>
|
||||
<component id="74001" class="javax.swing.JLabel" binding="smartZoomingWidthLabel">
|
||||
@@ -202,7 +202,7 @@
|
||||
<properties/>
|
||||
<border type="none" title-resource-bundle="org/intellij/images/ImagesBundle" title-key="external.editor.border.title"/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<children>
|
||||
<component id="55972" class="javax.swing.JLabel" binding="externalEditorLabel">
|
||||
|
||||
+4
@@ -857,6 +857,10 @@ public class AsmCodeGenerator {
|
||||
}
|
||||
pushBorderProperties(container, generator, borderTitle, componentLocal);
|
||||
|
||||
if (Boolean.valueOf(System.getProperty("idea.is.internal")).booleanValue()) {
|
||||
container.getDelegeeClientProperties().put(ourBorderFactoryClientProperty, "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent");
|
||||
}
|
||||
|
||||
Type borderFactoryType = ourBorderFactoryType;
|
||||
StringDescriptor borderFactoryValue = (StringDescriptor)container.getDelegeeClientProperties().get(ourBorderFactoryClientProperty);
|
||||
if (borderFactoryValue != null && borderFactoryValue.getValue().length() != 0) {
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
@@ -169,6 +170,26 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
return myModuleBytecodeTarget;
|
||||
}
|
||||
|
||||
public void setBytecodeTargetLevel(Module module, String level) {
|
||||
final String previous;
|
||||
if (StringUtil.isEmpty(level)) {
|
||||
previous = myModuleBytecodeTarget.remove(module.getName());
|
||||
}
|
||||
else {
|
||||
previous = myModuleBytecodeTarget.put(module.getName(), level);
|
||||
}
|
||||
if (!Comparing.equal(previous, level)) {
|
||||
final Project project = module.getProject();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (!project.isDisposed()) {
|
||||
CompileServerManager.getInstance().sendReloadRequest(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getBytecodeTargetLevel(Module module) {
|
||||
|
||||
@@ -2316,9 +2316,6 @@ public class CompileDriver {
|
||||
|
||||
private boolean validateCompilerConfiguration(final CompileScope scope, boolean checkOutputAndSourceIntersection) {
|
||||
try {
|
||||
if (useOutOfProcessBuild()) {
|
||||
return true;
|
||||
}
|
||||
final Module[] scopeModules = scope.getAffectedModules()/*ModuleManager.getInstance(myProject).getModules()*/;
|
||||
final List<String> modulesWithoutOutputPathSpecified = new ArrayList<String>();
|
||||
boolean isProjectCompilePathSpecified = true;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/CompilerBundle" title-key="eclipse.options.group.title"/>
|
||||
<children>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/CompilerBundle" title-key="javac.options.group.title"/>
|
||||
<children>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/CompilerBundle" title-key="jikes.options.group.title"/>
|
||||
<children>
|
||||
|
||||
+1
@@ -168,6 +168,7 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable,
|
||||
mainPanel.add(noteMessage, new GridBagConstraints(0, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
mainPanel.add(warning, new GridBagConstraints(0, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
mainPanel.add(myModulesTable, new GridBagConstraints(0, 6, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
//mainPanel.add(new AnnotationProcessorsPanel(myProject), new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
|
||||
|
||||
myRbClasspath.addItemListener(new ItemListener() {
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* 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.compiler.options;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ShortcutSet;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.InputValidatorEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.ui.EditableTreeModel;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "UseOfObsoleteCollectionType"})
|
||||
public class AnnotationProcessorsPanel extends JPanel {
|
||||
private final Map<String, List<Module>> profiles = new HashMap<String, List<Module>>();
|
||||
private static final String DEFAULT_PROFILE = "Default";
|
||||
private final Project myProject;
|
||||
private final Tree myTree;
|
||||
private JPanel myContentPanel;
|
||||
|
||||
public AnnotationProcessorsPanel(Project project) {
|
||||
super(new BorderLayout());
|
||||
myProject = project;
|
||||
loadProfiles();
|
||||
myTree = new Tree(new MyTreeModel());
|
||||
myTree.setRootVisible(false);
|
||||
final JPanel treePanel =
|
||||
ToolbarDecorator.createDecorator(myTree).addExtraAction(new AnActionButton("Move to", IconLoader.getIcon("/actions/nextfile.png")) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final MyModuleNode node = (MyModuleNode)myTree.getSelectionPath().getLastPathComponent();
|
||||
final TreePath[] selectedNodes = myTree.getSelectionPaths();
|
||||
final String key = ((MyProfileNode)node.getParent()).myKey;
|
||||
final List<String> profileNames = new ArrayList<String>();
|
||||
profileNames.add(DEFAULT_PROFILE);
|
||||
profileNames.addAll(profiles.keySet());
|
||||
profileNames.remove(key);
|
||||
final JBList list = new JBList(profileNames);
|
||||
final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list)
|
||||
.setTitle("Move to")
|
||||
.setItemChoosenCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Object value = list.getSelectedValue();
|
||||
if (value instanceof String) {
|
||||
final Module toSelect = (Module)node.getUserObject();
|
||||
if (selectedNodes != null) {
|
||||
for (TreePath selectedNode : selectedNodes) {
|
||||
final Object n = selectedNode.getLastPathComponent();
|
||||
|
||||
if (n instanceof MyModuleNode) {
|
||||
Module module = (Module)((MyModuleNode)n).getUserObject();
|
||||
if (!DEFAULT_PROFILE.equals(key)) {
|
||||
profiles.get(key).remove(module);
|
||||
}
|
||||
if (!DEFAULT_PROFILE.equals(value)) {
|
||||
profiles.get(value).add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final MyRootNode root = (MyRootNode)myTree.getModel().getRoot();
|
||||
root.sync();
|
||||
final DefaultMutableTreeNode node = TreeUtil.findNodeWithObject(root, toSelect);
|
||||
if (node != null) {
|
||||
TreeUtil.selectNode(myTree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.createPopup();
|
||||
RelativePoint point = e.getInputEvent() instanceof MouseEvent ? getPreferredPopupPoint() : TreeUtil.getPointForSelection(myTree);
|
||||
popup.show(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShortcutSet getShortcut() {
|
||||
return ActionManager.getInstance().getAction("Move").getShortcutSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myTree.getSelectionPath() != null
|
||||
&& myTree.getSelectionPath().getLastPathComponent() instanceof MyModuleNode
|
||||
&& !profiles.isEmpty();
|
||||
}
|
||||
}).createPanel();
|
||||
add(treePanel, BorderLayout.WEST);
|
||||
myTree.setCellRenderer(new MyCellRenderer());
|
||||
((MyRootNode)myTree.getModel().getRoot()).sync();
|
||||
myContentPanel = new JPanel(new BorderLayout());
|
||||
myTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
String currentProfile = null;
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
final TreePath path = myTree.getSelectionPath();
|
||||
if (path != null) {
|
||||
Object node = path.getLastPathComponent();
|
||||
if (node instanceof MyModuleNode) {
|
||||
node = ((MyModuleNode)node).getParent();
|
||||
}
|
||||
if (node instanceof MyProfileNode) {
|
||||
if (!StringUtil.equals(currentProfile, ((MyProfileNode)node).myKey)) {
|
||||
currentProfile = ((MyProfileNode)node).myKey;
|
||||
myContentPanel.removeAll();
|
||||
myContentPanel.add(getComponentForProfile(currentProfile), BorderLayout.CENTER);
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
add(myContentPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
private JComponent getComponentForProfile(String profile) {
|
||||
//TODO[jeka] correct panel
|
||||
return new JLabel(profile, SwingConstants.CENTER);
|
||||
}
|
||||
|
||||
private static void expand(JTree tree) {
|
||||
int oldRowCount = 0;
|
||||
do {
|
||||
int rowCount = tree.getRowCount();
|
||||
if (rowCount == oldRowCount) break;
|
||||
oldRowCount = rowCount;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
tree.expandRow(i);
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
|
||||
private void loadProfiles() {
|
||||
//TODO[jeka] init profiles map
|
||||
}
|
||||
|
||||
private class MyTreeModel extends DefaultTreeModel implements EditableTreeModel{
|
||||
public MyTreeModel() {
|
||||
super(new MyRootNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreePath addNode(TreePath parentOrNeighbour) {
|
||||
final String profile = Messages.showInputDialog(myProject, "Profile name", "Create new profile", null, "", new InputValidatorEx() {
|
||||
@Override
|
||||
public boolean checkInput(String inputString) {
|
||||
return !DEFAULT_PROFILE.equals(inputString) && !profiles.containsKey(inputString) && !StringUtil.isEmpty(inputString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canClose(String inputString) {
|
||||
return checkInput(inputString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorText(String inputString) {
|
||||
if (checkInput(inputString)) return null;
|
||||
return StringUtil.isEmpty(inputString) ? "Profile name shouldn't be empty"
|
||||
: "Profile " + inputString + " already exists";
|
||||
}
|
||||
});
|
||||
if (profile != null) {
|
||||
profiles.put(profile, new ArrayList<Module>());
|
||||
}
|
||||
((SyncWithMap)getRoot()).sync();
|
||||
final DefaultMutableTreeNode object = TreeUtil.findNodeWithObject((DefaultMutableTreeNode)getRoot(), profile);
|
||||
if (object != null) {
|
||||
TreeUtil.selectNode(myTree, object);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(TreePath parent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveNodeTo(TreePath parentOrNeighbour) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class MyRootNode extends DefaultMutableTreeNode implements SyncWithMap {
|
||||
@Override
|
||||
public SyncWithMap sync() {
|
||||
final Vector newKids = new Vector();
|
||||
for (String key : profiles.keySet()) {
|
||||
newKids.add(new MyProfileNode(key, this).sync());
|
||||
}
|
||||
newKids.add(new MyProfileNode(DEFAULT_PROFILE, this).sync());
|
||||
children = newKids;
|
||||
((DefaultTreeModel)myTree.getModel()).reload();
|
||||
expand(myTree);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private interface SyncWithMap {
|
||||
SyncWithMap sync();
|
||||
}
|
||||
|
||||
private class MyProfileNode extends DefaultMutableTreeNode implements SyncWithMap {
|
||||
private final String myKey;
|
||||
|
||||
public MyProfileNode(String key, MyRootNode parent) {
|
||||
super(key);
|
||||
setParent(parent);
|
||||
myKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyncWithMap sync() {
|
||||
final List<Module> nodeModules;
|
||||
if (DEFAULT_PROFILE.equals(myKey)) {
|
||||
final Module[] allModules = ModuleManager.getInstance(myProject).getSortedModules();
|
||||
nodeModules = new ArrayList<Module>(Arrays.asList(allModules));
|
||||
for (List<Module> modules : profiles.values()) {
|
||||
for (Module module : modules) {
|
||||
nodeModules.remove(module);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nodeModules = profiles.get(myKey);
|
||||
}
|
||||
final Vector vector = new Vector();
|
||||
for (Module module : nodeModules) {
|
||||
vector.add(new MyModuleNode(module, this));
|
||||
}
|
||||
children = vector;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private class MyModuleNode extends DefaultMutableTreeNode {
|
||||
public MyModuleNode(Module module, MyProfileNode parent) {
|
||||
super(module);
|
||||
setParent(parent);
|
||||
setAllowsChildren(false);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCellRenderer extends ColoredTreeCellRenderer {
|
||||
@Override
|
||||
public void customizeCellRenderer(JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
if (value instanceof MyProfileNode) {
|
||||
append(((MyProfileNode)value).myKey);
|
||||
} else if (value instanceof MyModuleNode) {
|
||||
final Module module = (Module)((MyModuleNode)value).getUserObject();
|
||||
setIcon(IconLoader.getIcon("/nodes/ModuleClosed.png"));
|
||||
append(module.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,8 @@ import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.*;
|
||||
import org.jboss.netty.channel.group.ChannelGroup;
|
||||
@@ -76,8 +78,7 @@ import org.jetbrains.jps.cmdline.BuildMain;
|
||||
import org.jetbrains.jps.server.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.server.Server;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
import javax.tools.*;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -525,7 +526,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
final String defaultCharset = EncodingManager.getInstance().getDefaultCharsetName();
|
||||
if (defaultCharset != null) {
|
||||
if (!StringUtil.isEmpty(defaultCharset)) {
|
||||
cmdBuilder.setGlobalEncoding(defaultCharset);
|
||||
}
|
||||
|
||||
@@ -845,8 +846,8 @@ public class BuildManager implements ApplicationComponent{
|
||||
|
||||
private static class ProjectData {
|
||||
final SequentialTaskExecutor taskQueue;
|
||||
private final Set<String> myChanged = new HashSet<String>();
|
||||
private final Set<String> myDeleted = new HashSet<String>();
|
||||
private final Set<String> myChanged = new THashSet<String>(PathHashingStrategy.INSTANCE);
|
||||
private final Set<String> myDeleted = new THashSet<String>(PathHashingStrategy.INSTANCE);
|
||||
private long myNextEventOrdinal = 0L;
|
||||
private boolean myNeedRescan = true;
|
||||
|
||||
@@ -891,6 +892,20 @@ public class BuildManager implements ApplicationComponent{
|
||||
myChanged.clear();
|
||||
myDeleted.clear();
|
||||
}
|
||||
|
||||
static class PathHashingStrategy implements TObjectHashingStrategy<String> {
|
||||
static final PathHashingStrategy INSTANCE = new PathHashingStrategy();
|
||||
|
||||
@Override
|
||||
public int computeHashCode(String path) {
|
||||
return FileUtil.pathHashCode(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(String path1, String path2) {
|
||||
return FileUtil.pathsEqual(path1, path2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public abstract class CompilerConfiguration {
|
||||
@Nullable
|
||||
public abstract String getBytecodeTargetLevel(Module module);
|
||||
|
||||
public abstract void setBytecodeTargetLevel(Module module, String level);
|
||||
|
||||
public static CompilerConfiguration getInstance(Project project) {
|
||||
return project.getComponent(CompilerConfiguration.class);
|
||||
}
|
||||
@@ -72,5 +74,4 @@ public abstract class CompilerConfiguration {
|
||||
public abstract boolean isAnnotationProcessingEnabled(Module module);
|
||||
|
||||
public abstract String getGeneratedSourceDirName(Module module);
|
||||
|
||||
}
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class DefaultCodeFragmentFactory extends CodeFragmentFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parameters.getInvocationCount() <= 1 && JavaCompletionUtil.containsMethodCalls(expression)) {
|
||||
if (parameters.getInvocationCount() <= 1 && JavaCompletionUtil.mayHaveSideEffects(expression)) {
|
||||
final CompletionService service = CompletionService.getCompletionService();
|
||||
if (service.getAdvertisementText() == null && parameters.getInvocationCount() < 2) {
|
||||
service.setAdvertisementText("Invoke completion once more to see runtime type variants");
|
||||
|
||||
@@ -33,9 +33,9 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.ui.popup.util.SplitterItem;
|
||||
import com.intellij.xdebugger.AbstractDebuggerSession;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
|
||||
import com.intellij.xdebugger.impl.actions.DebuggerToggleActionHandler;
|
||||
@@ -213,6 +213,11 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
return result.toArray(new AnAction[result.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideBreakpointsGroupingRules(Collection<XBreakpointGroupingRule> rules) {
|
||||
rules.add(new XBreakpointGroupingByCategoryRule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final BreakpointsListener listener, Project project) {
|
||||
final MyBreakpointManagerListener listener1 = new MyBreakpointManagerListener(listener);
|
||||
@@ -254,13 +259,10 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideBreakpointItems(Project project, Collection<ItemWrapper> items) {
|
||||
public void provideBreakpointItems(Project project, Collection<BreakpointItem> items) {
|
||||
for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) {
|
||||
Key<? extends Breakpoint> category = breakpointFactory.getBreakpointCategory();
|
||||
Breakpoint[] breakpoints = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpoints(category);
|
||||
if (breakpoints.length > 0) {
|
||||
items.add(new SplitterItem(breakpointFactory.getDisplayName()));
|
||||
}
|
||||
for (Breakpoint breakpoint : breakpoints) {
|
||||
items.add(breakpointFactory.createBreakpointItem(breakpoint));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: zajac
|
||||
* Date: 23.05.12
|
||||
* Time: 16:22
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class XBreakpointCategoryGroup extends XBreakpointGroup {
|
||||
private Key<? extends Breakpoint> myCategory;
|
||||
private Icon myIcon;
|
||||
private final String myName;
|
||||
|
||||
public XBreakpointCategoryGroup(BreakpointFactory factory) {
|
||||
myCategory = factory.getBreakpointCategory();
|
||||
myIcon = factory.getIcon();
|
||||
final String name = factory.getDisplayName();
|
||||
myName = name != null ? name : "UNKNOWN";
|
||||
}
|
||||
|
||||
public Key<? extends Breakpoint> getCategory() {
|
||||
return myCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean isOpen) {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.debugger.ui;
|
||||
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: zajac
|
||||
* Date: 23.05.12
|
||||
* Time: 16:24
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class XBreakpointGroupingByCategoryRule<B> extends XBreakpointGroupingRule<B, XBreakpointCategoryGroup> {
|
||||
XBreakpointGroupingByCategoryRule() {
|
||||
super("XBreakpointGroupingByCategoryRule", "Type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public XBreakpointCategoryGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointCategoryGroup> groups) {
|
||||
if (b instanceof Breakpoint) {
|
||||
final Breakpoint breakpoint = (Breakpoint)b;
|
||||
for (XBreakpointCategoryGroup group : groups) {
|
||||
if (group.getCategory().equals(breakpoint.getCategory())) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
final BreakpointFactory factory = BreakpointFactory.getInstance(breakpoint.getCategory());
|
||||
if (factory != null) {
|
||||
return new XBreakpointCategoryGroup(factory);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
|
||||
@@ -43,12 +43,11 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
renderer.setIcon(myBreakpoint.getIcon());
|
||||
renderer.append(myBreakpoint.getShortName());
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer) {
|
||||
//renderer.setIcon(myBreakpoint.getIcon());
|
||||
renderer.append(myBreakpoint.getShortName(), isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return myBreakpoint.getDisplayName();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -51,7 +52,7 @@ public class Convertor34 {
|
||||
private static final String JAVA_DOC_ROOTS_CANNOT_BE_CONVERTED = ProjectBundle.message("project.convert.javadoc.paths.error");
|
||||
private static final String MULTIPLE_OUTPUT_PATHS = ProjectBundle.message("project.convert.multiple.output.paths.error");
|
||||
|
||||
public static void execute(Element root, String filePath, ArrayList<String> conversionProblems) {
|
||||
public static void execute(Element root, String filePath, @Nullable ArrayList<String> conversionProblems) {
|
||||
if (filePath == null) return;
|
||||
|
||||
if (conversionProblems == null) {
|
||||
|
||||
+5
-5
@@ -30,7 +30,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ApplicationBundle" title-key="title.naming"/>
|
||||
<children>
|
||||
@@ -174,7 +174,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithoutIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ApplicationBundle" title-key="title.order.of.members"/>
|
||||
<children/>
|
||||
@@ -191,7 +191,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ApplicationBundle" title-key="title.naming.comment.code"/>
|
||||
<children>
|
||||
@@ -224,7 +224,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ApplicationBundle" title-key="title.naming.final.modifier"/>
|
||||
<children>
|
||||
@@ -263,7 +263,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Override Method Signature"/>
|
||||
<children>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Javadoc"/>
|
||||
<children>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Java">
|
||||
<size top="0" left="10" bottom="0" right="0"/>
|
||||
|
||||
@@ -77,6 +77,19 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
|
||||
psiClass.getTypeParameters().length > 0 &&
|
||||
((PsiTypeLookupItem)delegate).calcGenerics(position, context).isEmpty() &&
|
||||
context.getCompletionChar() != '(';
|
||||
|
||||
if (context.getDocument().getTextLength() > context.getTailOffset() &&
|
||||
context.getDocument().getCharsSequence().charAt(context.getTailOffset()) == '<') {
|
||||
PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getTailOffset(), PsiJavaCodeReferenceElement.class, false);
|
||||
if (ref != null) {
|
||||
PsiReferenceParameterList parameterList = ref.getParameterList();
|
||||
if (parameterList != null && context.getTailOffset() == parameterList.getTextRange().getStartOffset()) {
|
||||
context.getDocument().deleteString(parameterList.getTextRange().getStartOffset(), parameterList.getTextRange().getEndOffset());
|
||||
context.commitDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate.handleInsert(context);
|
||||
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
|
||||
}
|
||||
@@ -85,6 +98,7 @@ public class ConstructorInsertHandler implements InsertHandler<LookupElementDeco
|
||||
PsiTypeLookupItem.addImportForItem(context, psiClass);
|
||||
}
|
||||
|
||||
|
||||
insertParentheses(context, delegate, psiClass, !inAnonymous && isAbstract);
|
||||
|
||||
if (inAnonymous) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class JavaCompletionSorting {
|
||||
|
||||
List<LookupElementWeigher> afterNegativeStats = new ArrayList<LookupElementWeigher>();
|
||||
if (!smart) {
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, preferStatics(position));
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, preferStatics(position, expectedTypes));
|
||||
}
|
||||
afterNegativeStats.add(new PreferLocalVariablesLiteralsAndAnnoMethodsWeigher(type, position));
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, recursion(parameters, expectedTypes));
|
||||
@@ -126,7 +126,7 @@ public class JavaCompletionSorting {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LookupElementWeigher preferStatics(PsiElement position) {
|
||||
private static LookupElementWeigher preferStatics(PsiElement position, final ExpectedTypeInfo[] infos) {
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiDocComment.class) != null) {
|
||||
return null;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class JavaCompletionSorting {
|
||||
if (o instanceof PsiKeyword) return -3;
|
||||
if (!(o instanceof PsiMember)) return 0;
|
||||
|
||||
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC) && !hasNonVoid(infos)) {
|
||||
if (o instanceof PsiMethod) return -5;
|
||||
if (o instanceof PsiField) return -4;
|
||||
}
|
||||
@@ -179,14 +179,7 @@ public class JavaCompletionSorting {
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasNonVoid = false;
|
||||
for (ExpectedTypeInfo info : expectedInfos) {
|
||||
if (!PsiType.VOID.equals(info.getType())) {
|
||||
hasNonVoid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNonVoid) {
|
||||
if (hasNonVoid(expectedInfos)) {
|
||||
if (item.getObject() instanceof PsiKeyword) {
|
||||
String keyword = ((PsiKeyword)item.getObject()).getText();
|
||||
if (PsiKeyword.NEW.equals(keyword) || PsiKeyword.NULL.equals(keyword)) {
|
||||
@@ -201,6 +194,16 @@ public class JavaCompletionSorting {
|
||||
return ExpectedTypeMatching.normal;
|
||||
}
|
||||
|
||||
private static boolean hasNonVoid(ExpectedTypeInfo[] expectedInfos) {
|
||||
boolean hasNonVoid = false;
|
||||
for (ExpectedTypeInfo info : expectedInfos) {
|
||||
if (!PsiType.VOID.equals(info.getType())) {
|
||||
hasNonVoid = true;
|
||||
}
|
||||
}
|
||||
return hasNonVoid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getLookupObjectName(Object o) {
|
||||
if (o instanceof PsiVariable) {
|
||||
|
||||
+6
-10
@@ -62,17 +62,13 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
if (o instanceof PsiMember) {
|
||||
final boolean isClass = o instanceof PsiClass;
|
||||
if (qualifierType != null) {
|
||||
if (type == CompletionType.SMART) {
|
||||
String context;
|
||||
if (isClass) {
|
||||
context = JavaStatisticsManager.getAfterNewKey(qualifierType);
|
||||
} else {
|
||||
context = JavaStatisticsManager.getMemberUseKey1(qualifierType);
|
||||
}
|
||||
return new StatisticsInfo(context, JavaStatisticsManager.getMemberUseKey2((PsiMember)o));
|
||||
String context;
|
||||
if (isClass) {
|
||||
context = JavaStatisticsManager.getAfterNewKey(qualifierType);
|
||||
} else {
|
||||
context = JavaStatisticsManager.getMemberUseKey1(qualifierType);
|
||||
}
|
||||
if (!isClass && type == CompletionType.BASIC) return JavaStatisticsManager.createInfo(qualifierType, (PsiMember)o);
|
||||
return StatisticsInfo.EMPTY;
|
||||
return new StatisticsInfo(context, JavaStatisticsManager.getMemberUseKey2((PsiMember)o));
|
||||
}
|
||||
|
||||
if (isClass) {
|
||||
|
||||
@@ -677,18 +677,19 @@ public class JavaCompletionUtil {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiElement getQualifier(final PsiElement element) {
|
||||
return element instanceof PsiJavaCodeReferenceElement ? ((PsiJavaCodeReferenceElement)element).getQualifier() : null;
|
||||
}
|
||||
|
||||
public static boolean containsMethodCalls(@Nullable final PsiElement qualifier) {
|
||||
if (qualifier == null) return false;
|
||||
if (qualifier instanceof PsiMethodCallExpression || qualifier instanceof PsiNewExpression) return true;
|
||||
if (qualifier instanceof PsiArrayAccessExpression) {
|
||||
return containsMethodCalls(((PsiArrayAccessExpression)qualifier).getArrayExpression());
|
||||
public static boolean mayHaveSideEffects(@Nullable final PsiElement element) {
|
||||
if (element == null) return false;
|
||||
if (element instanceof PsiMethodCallExpression || element instanceof PsiNewExpression) return true;
|
||||
if (element instanceof PsiTypeCastExpression) {
|
||||
return mayHaveSideEffects(((PsiTypeCastExpression)element).getOperand());
|
||||
}
|
||||
return containsMethodCalls(getQualifier(qualifier));
|
||||
if (element instanceof PsiArrayAccessExpression) {
|
||||
return mayHaveSideEffects(((PsiArrayAccessExpression)element).getArrayExpression());
|
||||
}
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
return mayHaveSideEffects(((PsiJavaCodeReferenceElement)element).getQualifier());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void insertClassReference(@NotNull PsiClass psiClass, @NotNull PsiFile file, int offset) {
|
||||
|
||||
+15
-1
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.lookup.LookupElementWeigher;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.getters.MembersGetter;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -30,11 +31,13 @@ import java.util.Set;
|
||||
*/
|
||||
public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupElementWeigher {
|
||||
private final CompletionType myCompletionType;
|
||||
private final PsiElement myPosition;
|
||||
private final Set<PsiField> myNonInitializedFields;
|
||||
|
||||
public PreferLocalVariablesLiteralsAndAnnoMethodsWeigher(CompletionType completionType, PsiElement position) {
|
||||
super("local");
|
||||
myCompletionType = completionType;
|
||||
myPosition = position;
|
||||
myNonInitializedFields = JavaCompletionProcessor.getNonInitializedFields(position);
|
||||
}
|
||||
|
||||
@@ -60,7 +63,10 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
|
||||
|
||||
if (object instanceof PsiKeyword) {
|
||||
String keyword = ((PsiKeyword)object).getText();
|
||||
if (PsiKeyword.RETURN.equals(keyword) || PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
|
||||
if (PsiKeyword.RETURN.equals(keyword) && isLastStatement(PsiTreeUtil.getParentOfType(myPosition, PsiStatement.class))) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
|
||||
return MyResult.probableKeyword;
|
||||
}
|
||||
}
|
||||
@@ -118,4 +124,12 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
|
||||
|
||||
return MyResult.normal;
|
||||
}
|
||||
|
||||
private static boolean isLastStatement(PsiStatement statement) {
|
||||
if (statement == null || !(statement.getParent() instanceof PsiCodeBlock)) {
|
||||
return true;
|
||||
}
|
||||
PsiStatement[] siblings = ((PsiCodeBlock)statement.getParent()).getStatements();
|
||||
return statement == siblings[siblings.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -274,7 +274,9 @@ public class ReferenceExpressionCompletionContributor {
|
||||
}
|
||||
if (itemType == null) return;
|
||||
|
||||
final PsiElement qualifier = JavaCompletionUtil.getQualifier(reference.getElement());
|
||||
final PsiElement element1 = reference.getElement();
|
||||
final PsiElement qualifier =
|
||||
element1 instanceof PsiJavaCodeReferenceElement ? ((PsiJavaCodeReferenceElement)element1).getQualifier() : null;
|
||||
final PsiType expectedType = parameters.getExpectedType();
|
||||
if (!OBJECT_METHOD_PATTERN.accepts(object) || allowGetClass(object, parameters)) {
|
||||
if (parameters.getParameters().getInvocationCount() >= 3 || !itemType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
|
||||
@@ -398,7 +400,7 @@ public class ReferenceExpressionCompletionContributor {
|
||||
}
|
||||
|
||||
final String bracketSpace = getSpace(CodeStyleSettingsManager.getSettings(element.getProject()).SPACE_WITHIN_BRACKETS);
|
||||
if (object instanceof PsiVariable && !JavaCompletionUtil.containsMethodCalls(qualifier)) {
|
||||
if (object instanceof PsiVariable && !JavaCompletionUtil.mayHaveSideEffects(qualifier)) {
|
||||
final PsiVariable variable = (PsiVariable)object;
|
||||
addToArrayConversion(element, prefix,
|
||||
"new " + componentType.getCanonicalText() +
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.daemon.impl;
|
||||
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.FunctionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class RecursiveCallLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
private static final Icon RECURSIVE_METHOD_ICON = IconLoader.getIcon("/gutter/recursiveMethod.png");
|
||||
|
||||
@Override
|
||||
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
|
||||
return null; //do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
|
||||
final Set<PsiStatement> statements = new HashSet<PsiStatement>();
|
||||
|
||||
for (PsiElement element : elements) {
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
|
||||
final PsiStatement statement = PsiTreeUtil.getParentOfType(methodCall, PsiStatement.class, true, PsiMethod.class);
|
||||
if (!statements.contains(statement) && isRecursiveMethodCall(methodCall)) {
|
||||
statements.add(statement);
|
||||
result.add(new RecursiveMethodCallMarkerInfo(methodCall));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall) {
|
||||
final PsiMethod referencedMethod = methodCall.resolveMethod();
|
||||
|
||||
if (referencedMethod == null || !referencedMethod.isValid() || !methodCall.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiFile methodCallFile = methodCall.getContainingFile();
|
||||
final PsiFile methodFile = referencedMethod.getContainingFile();
|
||||
|
||||
if (methodCallFile == null || methodFile == null || !methodCallFile.equals(methodFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final TextRange rmRange = referencedMethod.getTextRange();
|
||||
final int mcOffset = methodCall.getTextRange().getStartOffset();
|
||||
return rmRange != null && rmRange.contains(mcOffset);
|
||||
}
|
||||
|
||||
private static class RecursiveMethodCallMarkerInfo extends LineMarkerInfo<PsiMethodCallExpression> {
|
||||
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) {
|
||||
super(methodCall,
|
||||
methodCall.getTextRange(),
|
||||
RECURSIVE_METHOD_ICON,
|
||||
Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive method call"),
|
||||
null,
|
||||
GutterIconRenderer.Alignment.RIGHT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -390,7 +390,7 @@ public class GenericsHighlightUtil {
|
||||
if (extendFrom == null) return null;
|
||||
HighlightInfo errorResult = null;
|
||||
if (!extendFrom.isInterface() && referenceElements.length != 0 && element != referenceElements[0]) {
|
||||
final String description = HighlightClassUtil.INTERFACE_EXPECTED;
|
||||
String description = JavaErrorMessages.message("interface.expected");
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, element, description);
|
||||
PsiClassType type =
|
||||
JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(extendFrom, resolveResult.getSubstitutor());
|
||||
|
||||
+34
-28
@@ -60,9 +60,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class HighlightClassUtil {
|
||||
public static final String INTERFACE_EXPECTED = JavaErrorMessages.message("interface.expected");
|
||||
public static final String NO_INTERFACE_EXPECTED = JavaErrorMessages.message("no.interface.expected");
|
||||
private static final String STATIC_DECLARATION_IN_INNER_CLASS = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
/**
|
||||
@@ -280,9 +277,8 @@ public class HighlightClassUtil {
|
||||
if (PsiUtil.isCompileTimeConstant(field)) {
|
||||
return null;
|
||||
}
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(field.getContainingClass(), PsiModifier.STATIC, true, false);
|
||||
@@ -297,9 +293,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiMethod method = (PsiMethod)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(method)) return null;
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix((PsiClass)keyword.getParent().getParent().getParent(), PsiModifier.STATIC, true, false);
|
||||
@@ -314,9 +309,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiClassInitializer initializer = (PsiClassInitializer)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(initializer)) return null;
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
keyword,
|
||||
STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, keyword, message);
|
||||
IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(initializer, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix1);
|
||||
PsiClass owner = (PsiClass)keyword.getParent().getParent().getParent();
|
||||
@@ -364,7 +358,8 @@ public class HighlightClassUtil {
|
||||
if (textRange == null) {
|
||||
textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
|
||||
}
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, STATIC_DECLARATION_IN_INNER_CLASS);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
if (context != keyword) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix);
|
||||
@@ -425,9 +420,8 @@ public class HighlightClassUtil {
|
||||
HighlightInfo errorResult = null;
|
||||
PsiClass extendFrom = (PsiClass)resolveResult.getElement();
|
||||
if (extendFrom.isInterface() != mustBeInterface) {
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
ref,
|
||||
mustBeInterface ? INTERFACE_EXPECTED : NO_INTERFACE_EXPECTED);
|
||||
String message = JavaErrorMessages.message(mustBeInterface ? "interface.expected" : "no.interface.expected");
|
||||
errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, ref, message);
|
||||
PsiClassType type =
|
||||
JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(ref);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new ChangeExtendsToImplementsFix(aClass, type));
|
||||
@@ -640,7 +634,8 @@ public class HighlightClassUtil {
|
||||
}
|
||||
|
||||
|
||||
public static HighlightInfo checkQualifiedNewOfStaticClass(PsiNewExpression expression) {
|
||||
@Nullable
|
||||
public static HighlightInfo checkQualifiedNew(PsiNewExpression expression) {
|
||||
PsiExpression qualifier = expression.getQualifier();
|
||||
if (qualifier == null) return null;
|
||||
PsiType type = expression.getType();
|
||||
@@ -652,18 +647,28 @@ public class HighlightClassUtil {
|
||||
return info;
|
||||
}
|
||||
PsiClass aClass = PsiUtil.resolveClassInType(type);
|
||||
if (aClass != null && aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
JavaErrorMessages.message("qualified.new.of.static.class"));
|
||||
if (!aClass.isEnum()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
HighlightInfo info = null;
|
||||
if (aClass != null) {
|
||||
if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
JavaErrorMessages.message("qualified.new.of.static.class"));
|
||||
if (!aClass.isEnum()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
|
||||
} else if (aClass instanceof PsiAnonymousClass) {
|
||||
final PsiClass baseClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)aClass).getBaseClassType());
|
||||
if (baseClass != null && baseClass.isInterface()) {
|
||||
info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
expression,
|
||||
"Anonymous class implements interface; cannot have qualifier for new");
|
||||
}
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(info, new RemoveNewQualifierFix(expression, aClass));
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -840,8 +845,9 @@ public class HighlightClassUtil {
|
||||
}
|
||||
PsiModifierListOwner staticParent = PsiUtil.getEnclosingStaticElement(place, outerClass);
|
||||
if (staticParent != null) {
|
||||
String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context",
|
||||
outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." + PsiKeyword.THIS);
|
||||
String element = outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." +
|
||||
(place instanceof PsiSuperExpression ? PsiKeyword.SUPER : PsiKeyword.THIS);
|
||||
String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context", element);
|
||||
HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, elementToHighlight, description);
|
||||
// make context not static or referenced class static
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false);
|
||||
|
||||
+16
-13
@@ -838,14 +838,19 @@ public class HighlightMethodUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkMethodCanHaveBody(PsiMethod method) {
|
||||
if (method.getBody() == null) return null;
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
|
||||
String message = null;
|
||||
if (aClass != null && aClass.isInterface()) {
|
||||
message = JavaErrorMessages.message("interface.methods.cannot.have.body");
|
||||
if (!PsiUtil.isExtensionMethod(method)) {
|
||||
message = JavaErrorMessages.message("interface.methods.cannot.have.body");
|
||||
}
|
||||
else {
|
||||
return HighlightUtil.checkExtensionMethodsFeature(method);
|
||||
}
|
||||
}
|
||||
else if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
message = JavaErrorMessages.message("abstract.methods.cannot.have.a.body");
|
||||
@@ -853,21 +858,19 @@ public class HighlightMethodUtil {
|
||||
else if (method.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
message = JavaErrorMessages.message("native.methods.cannot.have.a.body");
|
||||
}
|
||||
if (message == null) return null;
|
||||
|
||||
if (message != null) {
|
||||
TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method));
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && aClass != null && !aClass.isInterface()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
return info;
|
||||
TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, textRange, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method));
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && aClass != null && !aClass.isInterface()) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false);
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
}
|
||||
return null;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkConstructorCallMustBeFirstStatement(PsiReferenceExpression expression) {
|
||||
PsiElement methodCall = expression.getParent();
|
||||
if (!HighlightUtil.isSuperOrThisMethodCall(methodCall)) return null;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class HighlightUtil {
|
||||
private static final Map<String, Set<String>> ourClassInitializerIncompatibleModifiers;
|
||||
private static final Set<String> ourConstructorNotAllowedModifiers;
|
||||
|
||||
@NonNls private static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID";
|
||||
@NonNls public static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID";
|
||||
@NonNls private static final String SERIAL_PERSISTENT_FIELDS_FIELD_NAME = "serialPersistentFields";
|
||||
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
|
||||
|
||||
@@ -1328,14 +1328,13 @@ public class HighlightUtil {
|
||||
}
|
||||
if (aClass == null) return null;
|
||||
if (qualifier != null && aClass.isInterface()) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, HighlightClassUtil.NO_INTERFACE_EXPECTED);
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("no.interface.expected"));
|
||||
}
|
||||
if (!HighlightClassUtil.hasEnclosingInstanceInScope(aClass, expr, false)) {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
static String buildProblemWithStaticDescription(PsiElement refElement) {
|
||||
@@ -2481,7 +2480,8 @@ public class HighlightUtil {
|
||||
VARARGS(LanguageLevel.JDK_1_5, "feature.varargs"),
|
||||
DIAMOND_TYPES(LanguageLevel.JDK_1_7, "feature.diamond.types"),
|
||||
MULTI_CATCH(LanguageLevel.JDK_1_7, "feature.multi.catch"),
|
||||
TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources");
|
||||
TRY_WITH_RESOURCES(LanguageLevel.JDK_1_7, "feature.try.with.resources"),
|
||||
EXTENSION_METHODS(LanguageLevel.JDK_1_8, "feature.extension.methods");
|
||||
|
||||
private final LanguageLevel level;
|
||||
private final String key;
|
||||
@@ -2544,4 +2544,9 @@ public class HighlightUtil {
|
||||
public static HighlightInfo checkTryWithResourcesFeature(final PsiResourceVariable resourceVariable) {
|
||||
return checkFeature(resourceVariable.getParent(), Feature.TRY_WITH_RESOURCES);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkExtensionMethodsFeature(final PsiMethod method) {
|
||||
return checkFeature(method, Feature.EXTENSION_METHODS);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -698,7 +698,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override public void visitNewExpression(PsiNewExpression expression) {
|
||||
myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, null));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkAnonymousInheritFinal(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNewOfStaticClass(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkQualifiedNew(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkCreateInnerClassFromStaticContext(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkTypeParameterInstantiation(expression));
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -43,7 +44,6 @@ import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -565,9 +565,15 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasOnlyOneMethod(@NotNull PsiAnonymousClass anonymousClass) {
|
||||
if (anonymousClass.getFields().length != 0) {
|
||||
return false;
|
||||
private static boolean hasOnlyOneMethod(@NotNull PsiAnonymousClass anonymousClass, boolean checkResolve) {
|
||||
PsiField[] fields = anonymousClass.getFields();
|
||||
if (fields.length != 0) {
|
||||
if (fields.length == 1 && HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME.equals(fields[0].getName()) &&
|
||||
fields[0].hasModifierProperty(PsiModifier.STATIC)) {
|
||||
//ok
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (anonymousClass.getInitializers().length != 0) {
|
||||
return false;
|
||||
@@ -576,7 +582,20 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
return false;
|
||||
}
|
||||
|
||||
return anonymousClass.getMethods().length == 1;
|
||||
if (anonymousClass.getMethods().length != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkResolve) {
|
||||
PsiReferenceList throwsList = anonymousClass.getMethods()[0].getThrowsList();
|
||||
for (PsiClassType type : throwsList.getReferencedTypes()) {
|
||||
if (type.resolve() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean addClosureFolding(final PsiClass aClass, final Document document, final List<FoldingDescriptor> foldElements,
|
||||
@@ -594,7 +613,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
final PsiExpressionList argumentList = expression.getArgumentList();
|
||||
if (argumentList != null && argumentList.getExpressions().length == 0) {
|
||||
final PsiMethod[] methods = anonymousClass.getMethods();
|
||||
if (hasOnlyOneMethod(anonymousClass) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) {
|
||||
if (hasOnlyOneMethod(anonymousClass, !quick) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) {
|
||||
final PsiMethod method = methods[0];
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body != null) {
|
||||
@@ -626,35 +645,13 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
if (lastLineEnd > 0 && seq.charAt(lastLineEnd) == '\n') lastLineEnd--;
|
||||
if (lastLineEnd < firstLineStart) return false;
|
||||
|
||||
final String baseClassName = quick ?
|
||||
anonymousClass.getBaseClassReference().getReferenceName() :
|
||||
ObjectUtils.assertNotNull(anonymousClass.getBaseClassType().resolve()).getName();
|
||||
if (lastLineEnd >= seq.length() || firstLineStart >= seq.length() || firstLineStart < 0) {
|
||||
LOG.error("llE=" + lastLineEnd + "; fLS=" + firstLineStart + "; len=" + seq.length() + "rE=" + rangeEnd + "; class=" +
|
||||
baseClassName);
|
||||
}
|
||||
|
||||
final String params = StringUtil.join(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
|
||||
@Override
|
||||
public String fun(final PsiParameter psiParameter) {
|
||||
String typeName;
|
||||
if (quick) {
|
||||
PsiTypeElement typeElement = psiParameter.getTypeElement();
|
||||
assert typeElement != null;
|
||||
typeName = typeElement.getText();
|
||||
}
|
||||
else {
|
||||
typeName = psiParameter.getType().getPresentableText();
|
||||
}
|
||||
int genStart = typeName.indexOf('<');
|
||||
int genEnd = typeName.lastIndexOf('>');
|
||||
if (genStart > 0 && genEnd > 0) {
|
||||
typeName = typeName.substring(0, genStart) + typeName.substring(genEnd + 1);
|
||||
}
|
||||
return typeName + " " + psiParameter.getName();
|
||||
return psiParameter.getName();
|
||||
}
|
||||
}, ", ");
|
||||
@NonNls final String lambdas = baseClassName + "(" + params + ") {";
|
||||
@NonNls final String lambdas = "{" + params + " =>";
|
||||
|
||||
final int closureStart = expression.getTextRange().getStartOffset();
|
||||
final int closureEnd = expression.getTextRange().getEndOffset();
|
||||
|
||||
+7
-2
@@ -35,7 +35,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBase {
|
||||
public abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBase {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.GenerateGetterSetterHandlerBase");
|
||||
|
||||
static {
|
||||
@@ -44,7 +44,7 @@ abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBas
|
||||
public Collection<EncapsulatableClassMember> fun(PsiClass s) {
|
||||
if (s.getLanguage() != StdLanguages.JAVA) return Collections.emptyList();
|
||||
final List<EncapsulatableClassMember> result = new ArrayList<EncapsulatableClassMember>();
|
||||
for(PsiField field: s.getFields()) {
|
||||
for (PsiField field : s.getFields()) {
|
||||
if (!(field instanceof PsiEnumConstant)) {
|
||||
result.add(new PsiFieldMember(field));
|
||||
}
|
||||
@@ -75,6 +75,11 @@ abstract class GenerateGetterSetterHandlerBase extends GenerateMembersHandlerBas
|
||||
protected abstract String getNothingFoundMessage();
|
||||
protected abstract String getNothingAcceptedMessage();
|
||||
|
||||
public boolean canBeAppliedTo(PsiClass targetClass) {
|
||||
final ClassMember[] allMembers = getAllOriginalMembers(targetClass);
|
||||
return allMembers != null && allMembers.length != 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ClassMember[] getAllOriginalMembers(final PsiClass aClass) {
|
||||
final List<EncapsulatableClassMember> list = GenerateAccessorProviderRegistrar.getEncapsulatableClassMembers(aClass);
|
||||
|
||||
@@ -270,16 +270,13 @@ public class GenerateMembersUtil {
|
||||
final PsiType parameterType = parameter.getType();
|
||||
PsiType substituted = substituteType(substitutor, parameterType);
|
||||
@NonNls String paramName = parameter.getName();
|
||||
final String[] baseSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names;
|
||||
boolean isBaseNameGenerated = false;
|
||||
for (String s : baseSuggestions) {
|
||||
if (s.equals(paramName)) {
|
||||
isBaseNameGenerated = true;
|
||||
break;
|
||||
}
|
||||
boolean isBaseNameGenerated = true;
|
||||
final boolean isSubstituted = substituted.equals(parameterType);
|
||||
if (!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName)) {
|
||||
isBaseNameGenerated = false;
|
||||
}
|
||||
|
||||
if (paramName == null || isBaseNameGenerated && !substituted.equals(parameterType)) {
|
||||
|
||||
if (paramName == null || isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName)) {
|
||||
Pair<String, Integer> pair = m.get(substituted);
|
||||
if (pair != null) {
|
||||
paramName = pair.first + pair.second;
|
||||
@@ -339,6 +336,18 @@ public class GenerateMembersUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBaseNameGenerated(JavaCodeStyleManager codeStyleManager, PsiType parameterType, String paramName) {
|
||||
final String[] baseSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, parameterType).names;
|
||||
boolean isBaseNameGenerated = false;
|
||||
for (String s : baseSuggestions) {
|
||||
if (s.equals(paramName)) {
|
||||
isBaseNameGenerated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isBaseNameGenerated;
|
||||
}
|
||||
|
||||
private static void processAnnotations(Project project, PsiModifierList modifierList, GlobalSearchScope moduleScope) {
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final Set<String> toRemove = new HashSet<String>();
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class JavaImplementMethodsHandler implements LanguageCodeInsightActionHan
|
||||
}
|
||||
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(file.getProject(), editor, file, false);
|
||||
return aClass != null;
|
||||
return aClass != null && !OverrideImplementUtil.getMethodSignaturesToImplement(aClass).isEmpty();
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
|
||||
|
||||
+13
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.lang.LanguageCodeInsightActionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -28,14 +29,23 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class JavaOverrideMethodsHandler implements LanguageCodeInsightActionHandler {
|
||||
public boolean isValidFor(final Editor editor, final PsiFile file) {
|
||||
return file instanceof PsiJavaFile && OverrideImplementUtil.getContextClass(file.getProject(), editor, file, true) != null;
|
||||
if (!(file instanceof PsiJavaFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(file.getProject(), editor, file, true);
|
||||
return aClass != null && !OverrideImplementUtil.getMethodSignaturesToOverride(aClass).isEmpty();
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
|
||||
PsiClass aClass = OverrideImplementUtil.getContextClass(project, editor, file, true);
|
||||
if (aClass != null) {
|
||||
OverrideImplementUtil.chooseAndOverrideMethods(project, editor, aClass);
|
||||
if (aClass == null) return;
|
||||
|
||||
if (OverrideImplementUtil.getMethodSignaturesToOverride(aClass).isEmpty()) {
|
||||
HintManager.getInstance().showErrorHint(editor, "No methods to override have been found");
|
||||
return;
|
||||
}
|
||||
OverrideImplementUtil.chooseAndOverrideMethods(project, editor, aClass);
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
|
||||
+2
-3
@@ -21,10 +21,9 @@ import com.intellij.codeInsight.generation.GenerateGetterHandler;
|
||||
* Action group which contains Generate... actions
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateGetterAction extends BaseGenerateAction {
|
||||
*/
|
||||
public class GenerateGetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateGetterAction() {
|
||||
super(new GenerateGetterHandler());
|
||||
}
|
||||
|
||||
}
|
||||
+1
-2
@@ -22,9 +22,8 @@ import com.intellij.codeInsight.generation.GenerateGetterAndSetterHandler;
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateGetterAndSetterAction extends BaseGenerateAction {
|
||||
public class GenerateGetterAndSetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateGetterAndSetterAction() {
|
||||
super(new GenerateGetterAndSetterHandler());
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.generation.actions;
|
||||
|
||||
import com.intellij.codeInsight.generation.GenerateGetterSetterHandlerBase;
|
||||
import com.intellij.psi.PsiClass;
|
||||
|
||||
/**
|
||||
* Action group which contains Generate... actions
|
||||
* Available in the Java code editor context only
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public abstract class GenerateGetterSetterBaseAction extends BaseGenerateAction {
|
||||
public GenerateGetterSetterBaseAction(GenerateGetterSetterHandlerBase handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidForClass(PsiClass targetClass) {
|
||||
final GenerateGetterSetterHandlerBase handler = (GenerateGetterSetterHandlerBase)getHandler();
|
||||
return handler.canBeAppliedTo(targetClass);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ import com.intellij.codeInsight.generation.GenerateSetterHandler;
|
||||
* Available in the Java code editor context only
|
||||
* @author Alexey Kudravtsev
|
||||
*/
|
||||
public class GenerateSetterAction extends BaseGenerateAction {
|
||||
public class GenerateSetterAction extends GenerateGetterSetterBaseAction {
|
||||
public GenerateSetterAction() {
|
||||
super(new GenerateSetterHandler());
|
||||
}
|
||||
|
||||
@@ -1075,38 +1075,33 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
startElement(expression);
|
||||
|
||||
DfaValue dfaValue = myFactory.create(expression);
|
||||
if (dfaValue != null) {
|
||||
addInstruction(new PushInstruction(dfaValue, expression));
|
||||
}
|
||||
else {
|
||||
PsiExpression condition = expression.getCondition();
|
||||
PsiExpression condition = expression.getCondition();
|
||||
|
||||
PsiExpression thenExpression = expression.getThenExpression();
|
||||
PsiExpression elseExpression = expression.getElseExpression();
|
||||
PsiExpression thenExpression = expression.getThenExpression();
|
||||
PsiExpression elseExpression = expression.getElseExpression();
|
||||
|
||||
final int elseOffset = elseExpression == null ? getEndOffset(expression) - 1 : getStartOffset(elseExpression);
|
||||
if (thenExpression != null) {
|
||||
condition.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
|
||||
PsiType type = expression.getType();
|
||||
addInstruction(new ConditionalGotoInstruction(elseOffset, true, condition));
|
||||
thenExpression.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(thenExpression,type);
|
||||
final int elseOffset = elseExpression == null ? getEndOffset(expression) - 1 : getStartOffset(elseExpression);
|
||||
if (thenExpression != null) {
|
||||
condition.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(condition, PsiType.BOOLEAN);
|
||||
PsiType type = expression.getType();
|
||||
addInstruction(new ConditionalGotoInstruction(elseOffset, true, condition));
|
||||
thenExpression.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(thenExpression,type);
|
||||
|
||||
addInstruction(new GotoInstruction(getEndOffset(expression)));
|
||||
addInstruction(new GotoInstruction(getEndOffset(expression)));
|
||||
|
||||
if (elseExpression != null) {
|
||||
elseExpression.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(elseExpression,type);
|
||||
}
|
||||
else {
|
||||
pushUnknown();
|
||||
}
|
||||
if (elseExpression != null) {
|
||||
elseExpression.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(elseExpression,type);
|
||||
}
|
||||
else {
|
||||
pushUnknown();
|
||||
}
|
||||
}
|
||||
else {
|
||||
pushUnknown();
|
||||
}
|
||||
|
||||
finishElement(expression);
|
||||
}
|
||||
|
||||
@@ -725,12 +725,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
if (!myHasDirtyFields) return;
|
||||
|
||||
myHasDirtyFields = false;
|
||||
DfaVariableValue[] fields = runner.getFields();
|
||||
for (DfaVariableValue field : fields) {
|
||||
boolean resetNullability = isNotNull(field);
|
||||
for (DfaVariableValue field : runner.getFields()) {
|
||||
flushVariable(field);
|
||||
if (resetNullability) {
|
||||
}
|
||||
getVariableState(field).setNullable(false);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
@@ -266,7 +267,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
|
||||
private static boolean isSerializationImplicitlyUsedField(PsiField field) {
|
||||
@NonNls final String name = field.getName();
|
||||
if (!"serialVersionUID".equals(name) && !"serialPersistentFields".equals(name)) return false;
|
||||
if (!HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME.equals(name) && !"serialPersistentFields".equals(name)) return false;
|
||||
if (!field.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
PsiClass aClass = field.getContainingClass();
|
||||
return aClass == null || isSerializable(aClass, null);
|
||||
|
||||
@@ -125,13 +125,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
if (node == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final IElementType type = node.getElementType();
|
||||
if (type == JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
|
||||
if (type == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) {
|
||||
return PsiTreeUtil.getParentOfType(parent, PsiDocMethodOrFieldRef.class) != null;
|
||||
}
|
||||
|
||||
return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG
|
||||
|| type == JavaDocElementType.DOC_INLINE_TAG;
|
||||
return type == JavaDocElementType.DOC_COMMENT || type == JavaDocElementType.DOC_TAG || type == JavaDocElementType.DOC_INLINE_TAG;
|
||||
}
|
||||
|
||||
private void init(final ASTNode child) {
|
||||
@@ -1096,9 +1096,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
else if (myRole1 == ChildRole.OPERATION_SIGN) {
|
||||
createSpaceInCode(mySettings.SPACE_AROUND_UNARY_OPERATOR);
|
||||
}
|
||||
else if (myChild1.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_TOKEN
|
||||
&& myChild2.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_TOKEN)
|
||||
{
|
||||
else if ((myType1 == JavaDocTokenType.DOC_TAG_VALUE_TOKEN || myType1 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) &&
|
||||
(myType2 == JavaDocTokenType.DOC_TAG_VALUE_TOKEN || myType2 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT)) {
|
||||
createSpaceInCode(true);
|
||||
}
|
||||
else if (myRole1 == ChildRole.COMMA) {
|
||||
@@ -1516,7 +1515,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override public void visitDocTag(PsiDocTag tag) {
|
||||
if (myChild1.getElementType() == JavaDocTokenType.DOC_TAG_NAME && myChild2.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_TOKEN) {
|
||||
if (myType1 == JavaDocTokenType.DOC_TAG_NAME && myType2 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) {
|
||||
myResult = Spacing.createSpacing(1, 1, 0, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,10 +22,9 @@ import com.intellij.psi.tree.IElementType;
|
||||
* @author max
|
||||
*/
|
||||
public class JavaASTFactory extends CoreJavaASTFactory {
|
||||
|
||||
@Override
|
||||
public CompositeElement createComposite(final IElementType type) {
|
||||
if (type == DOC_TAG_VALUE_TOKEN) {
|
||||
if (type == DOC_TAG_VALUE_ELEMENT) {
|
||||
return new PsiDocTagValueImpl();
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +318,9 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
@PsiModifier.ModifierConstant
|
||||
@Nullable
|
||||
public static String getAccessModifier(int accessLevel) {
|
||||
return accessLevel > accessModifiers.length ? null : accessModifiers[accessLevel - 1];
|
||||
@SuppressWarnings("UnnecessaryLocalVariable") @PsiModifier.ModifierConstant
|
||||
final String modifier = accessLevel > accessModifiers.length ? null : accessModifiers[accessLevel - 1];
|
||||
return modifier;
|
||||
}
|
||||
|
||||
private static final String[] accessModifiers = {
|
||||
@@ -952,4 +954,12 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
public static boolean isIgnoredName(@Nullable final String name) {
|
||||
return "ignore".equals(name) || "ignored".equals(name);
|
||||
}
|
||||
|
||||
public static boolean isExtensionMethod(@Nullable final PsiMethod method) {
|
||||
if (method == null) return false;
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body == null) return false;
|
||||
final PsiElement previous = PsiTreeUtil.skipSiblingsBackward(body, PsiComment.class, PsiWhiteSpace.class);
|
||||
return isJavaToken(previous, JavaTokenType.DEFAULT_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -147,7 +147,7 @@ public class JavadocParser {
|
||||
final PsiBuilder.Marker tagValue = builder.mark();
|
||||
builder.remapCurrentToken(JavaDocElementType.DOC_REFERENCE_HOLDER);
|
||||
builder.advanceLexer();
|
||||
tagValue.done(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
else if (!isInline && tagName != null && tagName.equals(PARAM_TAG)) {
|
||||
parseSimpleTagValue(builder, true);
|
||||
@@ -187,7 +187,7 @@ public class JavadocParser {
|
||||
else {
|
||||
final PsiBuilder.Marker tagValue = builder.mark();
|
||||
builder.advanceLexer();
|
||||
tagValue.done(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
tagValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class JavadocParser {
|
||||
}
|
||||
}
|
||||
else if (tokenType == JavaDocTokenType.DOC_TAG_VALUE_RPAREN) {
|
||||
subValue.done(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
subValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
builder.advanceLexer();
|
||||
refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
|
||||
return;
|
||||
@@ -227,7 +227,7 @@ public class JavadocParser {
|
||||
}
|
||||
}
|
||||
|
||||
subValue.done(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
subValue.done(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
|
||||
refStart.done(JavaDocElementType.DOC_METHOD_OR_FIELD_REF);
|
||||
@@ -238,7 +238,7 @@ public class JavadocParser {
|
||||
while (TAG_VALUES_SET.contains(getTokenType(builder))) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
tagValue.done(parameter ? JavaDocElementType.DOC_PARAMETER_REF : JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -264,13 +264,31 @@ public class PsiSuperMethodImplUtil {
|
||||
PsiMethod superMethod = superSignatureHierarchical.getMethod();
|
||||
PsiClass superClass = superMethod.getContainingClass();
|
||||
PsiClass containingClass = hierarchicalMethodSignature.getMethod().getContainingClass();
|
||||
return !superMethod.isConstructor()
|
||||
&& !aClass.equals(superClass)
|
||||
&& PsiUtil.isAccessible(superMethod, aClass, aClass)
|
||||
&& MethodSignatureUtil.isSubsignature(superSignatureHierarchical, hierarchicalMethodSignature)
|
||||
&& superClass != null
|
||||
&& (containingClass != null && containingClass.isInterface() == superClass.isInterface() || superClass.isInterface() || "java.lang.Object".equals(superClass.getQualifiedName()))
|
||||
;
|
||||
if (!superMethod.isConstructor()) {
|
||||
if (!aClass.equals(superClass)) {
|
||||
if (PsiUtil.isAccessible(superMethod, aClass, aClass)) {
|
||||
if (MethodSignatureUtil.isSubsignature(superSignatureHierarchical, hierarchicalMethodSignature)) {
|
||||
if (superClass != null) {
|
||||
if (superClass.isInterface() ||
|
||||
"java.lang.Object".equals(superClass.getQualifiedName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (containingClass != null) {
|
||||
if (!containingClass.isInterface()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!aClass.isInterface() && !InheritanceUtil.isInheritorOrSelf(superClass, containingClass, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static HierarchicalMethodSignatureImpl copy(HierarchicalMethodSignature hi) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ package com.intellij.psi.impl.cache;
|
||||
* @author max
|
||||
*/
|
||||
public interface ModifierFlags {
|
||||
// ---- The group equal to corresponding in ClsUtil.ACC_*
|
||||
int PUBLIC_MASK = 0x0001;
|
||||
int PRIVATE_MASK = 0x0002;
|
||||
int PROTECTED_MASK = 0x0004;
|
||||
@@ -31,9 +30,8 @@ public interface ModifierFlags {
|
||||
int TRANSIENT_MASK = 0x0080;
|
||||
int NATIVE_MASK = 0x0100;
|
||||
int INTERFACE_MASK = 0x0200;
|
||||
int DEFENDER_MASK = 0x0200;
|
||||
int ABSTRACT_MASK = 0x0400;
|
||||
// ---- End of the group equal to corresponding in ClsUtil.ACC_*
|
||||
|
||||
int STRICTFP_MASK = 0x0800;
|
||||
int PACKAGE_LOCAL_MASK = 0x1000;
|
||||
int DEPRECATED_MASK = 0x2000;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,12 +30,8 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.CharTable;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -123,7 +119,7 @@ public class RecordUtil {
|
||||
else if (parent instanceof PsiMethodStub) {
|
||||
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
|
||||
alreadyPublic = true;
|
||||
alreadyAbstract = true;
|
||||
alreadyAbstract = !((PsiMethodStub)parent).isDefender();
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiFieldStub) {
|
||||
@@ -143,27 +139,37 @@ public class RecordUtil {
|
||||
for (final LighterASTNode child : tree.getChildren(modList)) {
|
||||
final IElementType type = child.getTokenType();
|
||||
|
||||
if(type == JavaTokenType.PUBLIC_KEYWORD) {
|
||||
if (type == JavaTokenType.PUBLIC_KEYWORD) {
|
||||
alreadyPublic = true;
|
||||
} else if(type == JavaTokenType.PRIVATE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.PRIVATE_KEYWORD) {
|
||||
packed |= ModifierFlags.PRIVATE_MASK;
|
||||
} else if(type == JavaTokenType.PROTECTED_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.PROTECTED_KEYWORD) {
|
||||
packed |= ModifierFlags.PROTECTED_MASK;
|
||||
} else if(type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
alreadyAbstract =true;
|
||||
} else if (type == JavaTokenType.FINAL_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
alreadyAbstract = true;
|
||||
}
|
||||
else if (type == JavaTokenType.FINAL_KEYWORD) {
|
||||
alreadyFinal = true;
|
||||
} else if (type == JavaTokenType.STATIC_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.STATIC_KEYWORD) {
|
||||
alreadyStatic = true;
|
||||
} else if(type == JavaTokenType.NATIVE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.NATIVE_KEYWORD) {
|
||||
packed |= ModifierFlags.NATIVE_MASK;
|
||||
} else if (type == JavaTokenType.SYNCHRONIZED_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.SYNCHRONIZED_KEYWORD) {
|
||||
packed |= ModifierFlags.SYNCHRONIZED_MASK;
|
||||
} else if (type == JavaTokenType.TRANSIENT_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.TRANSIENT_KEYWORD) {
|
||||
packed |= ModifierFlags.TRANSIENT_MASK;
|
||||
} else if (type == JavaTokenType.VOLATILE_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.VOLATILE_KEYWORD) {
|
||||
packed |= ModifierFlags.VOLATILE_MASK;
|
||||
} else if (type == JavaTokenType.STRICTFP_KEYWORD) {
|
||||
}
|
||||
else if (type == JavaTokenType.STRICTFP_KEYWORD) {
|
||||
packed |= ModifierFlags.STRICTFP_MASK;
|
||||
}
|
||||
}
|
||||
@@ -175,8 +181,7 @@ public class RecordUtil {
|
||||
|
||||
if ((packed & ModifierFlags.PRIVATE_MASK) == 0 &&
|
||||
(packed & ModifierFlags.PROTECTED_MASK) == 0 &&
|
||||
(packed & ModifierFlags.PUBLIC_MASK) == 0
|
||||
) {
|
||||
(packed & ModifierFlags.PUBLIC_MASK) == 0) {
|
||||
packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
|
||||
}
|
||||
|
||||
@@ -217,62 +222,6 @@ public class RecordUtil {
|
||||
return (ourModifierNameToFlagMap.get(psiModifier) & packed) != 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private static final Set<String>[] SET_INSTANCES = new Set[8 * 4];
|
||||
|
||||
private static final String[] VISIBILITY_MODIFIERS = {null, PsiModifier.PUBLIC, PsiModifier.PRIVATE, PsiModifier.PROTECTED};
|
||||
|
||||
private static final int[] MODIFIER_MAP = {0, 1, 2, -1, 3, -1, -1, -1, -1};
|
||||
|
||||
static {
|
||||
SET_INSTANCES[0] = Collections.emptySet();
|
||||
for (int i = 1; i < 4; i++) {
|
||||
SET_INSTANCES[i << 3] = Collections.singleton(VISIBILITY_MODIFIERS[i]);
|
||||
}
|
||||
|
||||
for (int i = 1; i < 8; i++) {
|
||||
int attr = i << 3;
|
||||
|
||||
Set<String> set = new LinkedHashSet<String>();
|
||||
if ((attr & ModifierFlags.STATIC_MASK) != 0) set.add(PsiModifier.STATIC);
|
||||
if ((attr & ModifierFlags.FINAL_MASK) != 0) set.add(PsiModifier.FINAL);
|
||||
if ((attr & (4 << 3)) != 0) set.add(PsiModifier.ABSTRACT);
|
||||
|
||||
if (set.size() == 1) set = Collections.singleton(set.iterator().next());
|
||||
|
||||
SET_INSTANCES[i] = set;
|
||||
|
||||
for (int k = 1; k < 4; k++) {
|
||||
Set<String> setWithModifier = new LinkedHashSet<String>();
|
||||
setWithModifier.add(VISIBILITY_MODIFIERS[k]);
|
||||
setWithModifier.addAll(set);
|
||||
assert setWithModifier.size() > 1;
|
||||
|
||||
SET_INSTANCES[(k << 3) + i] = setWithModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getModifierSet(int modifiers) {
|
||||
assert (modifiers & ~(ModifierFlags.PUBLIC_MASK | ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK |
|
||||
ModifierFlags.FINAL_MASK | ModifierFlags.ABSTRACT_MASK | ModifierFlags.STATIC_MASK)) == 0;
|
||||
|
||||
int visibilityModifierIndex = MODIFIER_MAP[modifiers & 7];
|
||||
int index = ((modifiers >>> 3) & 3) + ((modifiers & ModifierFlags.ABSTRACT_MASK) >>> 8);
|
||||
if (visibilityModifierIndex != -1) {
|
||||
return SET_INSTANCES[index + (visibilityModifierIndex << 3)];
|
||||
}
|
||||
|
||||
Set<String> res = new LinkedHashSet<String>();
|
||||
if ((modifiers & ModifierFlags.PUBLIC_MASK) != 0) res.add(PsiModifier.PUBLIC);
|
||||
if ((modifiers & ModifierFlags.PRIVATE_MASK) != 0) res.add(PsiModifier.PRIVATE);
|
||||
if ((modifiers & ModifierFlags.PROTECTED_MASK) != 0) res.add(PsiModifier.PROTECTED);
|
||||
|
||||
res.addAll(SET_INSTANCES[index]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String intern(final CharTable table, final LighterASTNode node) {
|
||||
assert node instanceof LighterASTTokenNode;
|
||||
return table.intern(((LighterASTTokenNode)node).getText()).toString();
|
||||
|
||||
@@ -58,6 +58,10 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0";
|
||||
public static final String FLOAT_NAN = "0.0f / 0.0";
|
||||
|
||||
@NonNls private static final String SYNTHETIC_CLASS_INIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
|
||||
private static final int ACC_DEFENDER = Opcodes.ACC_INTERFACE; // todo[r.sh] use right constant once ASM gets Java 8 support
|
||||
|
||||
private final InnerClassSourceStrategy<T> myInnersStrategy;
|
||||
private final StubElement myParent;
|
||||
@@ -65,8 +69,6 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
private final T mySource;
|
||||
private PsiModifierListStub myModList;
|
||||
private PsiClassStub myResult;
|
||||
@NonNls private static final String SYNTHETIC_CLINIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
private JavaLexer myLexer;
|
||||
|
||||
public StubBuildingVisitor(final T classSource, InnerClassSourceStrategy<T> innersStrategy, final StubElement parent, final int access) {
|
||||
@@ -174,20 +176,25 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
return convertedSuper;
|
||||
}
|
||||
|
||||
// for lexer, so need not to be precise
|
||||
private static LanguageLevel convertFromVersion(final int version) {
|
||||
if (version == Opcodes.V1_1 || version == Opcodes.V1_2 || version == Opcodes.V1_3) {
|
||||
return LanguageLevel.JDK_1_3;
|
||||
}
|
||||
switch (version) {
|
||||
case Opcodes.V1_1:
|
||||
case Opcodes.V1_2:
|
||||
case Opcodes.V1_3:
|
||||
return LanguageLevel.JDK_1_3;
|
||||
|
||||
if (version == Opcodes.V1_4) {
|
||||
return LanguageLevel.JDK_1_4;
|
||||
}
|
||||
case Opcodes.V1_4:
|
||||
return LanguageLevel.JDK_1_4;
|
||||
|
||||
if (version == Opcodes.V1_5 || version == Opcodes.V1_6) {
|
||||
return LanguageLevel.JDK_1_5;
|
||||
}
|
||||
case Opcodes.V1_5:
|
||||
case Opcodes.V1_6:
|
||||
case Opcodes.V1_7:
|
||||
return LanguageLevel.JDK_1_5;
|
||||
|
||||
return LanguageLevel.HIGHEST;
|
||||
default:
|
||||
return LanguageLevel.HIGHEST;
|
||||
}
|
||||
}
|
||||
|
||||
private static int packCommonFlags(final int access) {
|
||||
@@ -357,16 +364,17 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
// However Scala compiler erroneously generates ACC_BRIDGE instead of ACC_SYNTHETIC flag for in-trait implementation delegation. See IDEA-78649
|
||||
if (isSynthetic) return null;
|
||||
|
||||
if (SYNTHETIC_CLINIT_METHOD.equals(name)) return null;
|
||||
if (SYNTHETIC_CLASS_INIT_METHOD.equals(name)) return null;
|
||||
|
||||
boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
|
||||
boolean isConstructor = SYNTHETIC_INIT_METHOD.equals(name);
|
||||
boolean isVarargs = (access & Opcodes.ACC_VARARGS) != 0;
|
||||
boolean isAnnotationMethod = myResult.isAnnotationType();
|
||||
boolean isDefender = (access & ACC_DEFENDER) != 0;
|
||||
|
||||
if (!isConstructor && !isCorrectName(name)) return null;
|
||||
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnnotationMethod, isVarargs, isDeprecated, false, isDefender);
|
||||
|
||||
String canonicalMethodName = isConstructor ? myResult.getName() : name;
|
||||
final List<String> args = new ArrayList<String>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,6 +73,7 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
boolean isVarArgs = false;
|
||||
boolean isDeprecatedByComment = false;
|
||||
boolean hasDeprecatedAnnotation = false;
|
||||
boolean isDefender = false;
|
||||
String defValueText = null;
|
||||
|
||||
boolean expectingDef = false;
|
||||
@@ -102,16 +103,20 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
else if (type == JavaTokenType.DEFAULT_KEYWORD) {
|
||||
expectingDef = true;
|
||||
}
|
||||
else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) &&
|
||||
type != JavaTokenType.SEMICOLON && type != JavaElementType.CODE_BLOCK) {
|
||||
defValueText = LightTreeUtil.toFilteredString(tree, child, null);
|
||||
else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
|
||||
if (type != JavaElementType.CODE_BLOCK) {
|
||||
defValueText = LightTreeUtil.toFilteredString(tree, child, null);
|
||||
}
|
||||
else {
|
||||
isDefender = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
|
||||
final boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation);
|
||||
final byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation, isDefender);
|
||||
|
||||
return new PsiMethodStubImpl(parentStub, StringRef.fromString(name), typeInfo, flags, StringRef.fromString(defValueText));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ public interface PsiMethodStub extends NamedStub<PsiMethod> {
|
||||
boolean isConstructor();
|
||||
boolean isVarArgs();
|
||||
boolean isAnnotationMethod();
|
||||
boolean isDefender();
|
||||
|
||||
@Nullable String getDefaultValueText();
|
||||
@NotNull TypeInfo getReturnTypeText(boolean doResolve);
|
||||
|
||||
+18
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,6 +43,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
private static final int ANNOTATION = 0x04;
|
||||
private static final int DEPRECATED = 0x08;
|
||||
private static final int DEPRECATED_ANNOTATION = 0x10;
|
||||
private static final int DEFENDER = 0x20;
|
||||
|
||||
|
||||
public PsiMethodStubImpl(final StubElement parent,
|
||||
@@ -88,6 +89,11 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
return isAnnotationMethod(myFlags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefender() {
|
||||
return (myFlags & DEFENDER) != 0;
|
||||
}
|
||||
|
||||
public static boolean isAnnotationMethod(final byte flags) {
|
||||
return (flags & ANNOTATION) != 0;
|
||||
}
|
||||
@@ -145,13 +151,19 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
myDefaultValueText = StringRef.fromString(defaultValueText);
|
||||
}
|
||||
|
||||
public static byte packFlags(boolean isConstructor, boolean isAnnotationMethod, boolean isVarargs, boolean isDeprecated, boolean hasDeprecatedAnnotation) {
|
||||
public static byte packFlags(boolean isConstructor,
|
||||
boolean isAnnotationMethod,
|
||||
boolean isVarargs,
|
||||
boolean isDeprecated,
|
||||
boolean hasDeprecatedAnnotation,
|
||||
boolean isDefender) {
|
||||
byte flags = 0;
|
||||
if (isConstructor) flags |= CONSTRUCTOR;
|
||||
if (isAnnotationMethod) flags |= ANNOTATION;
|
||||
if (isVarargs) flags |= VARARGS;
|
||||
if (isDeprecated) flags |= DEPRECATED;
|
||||
if (hasDeprecatedAnnotation) flags |= DEPRECATED_ANNOTATION;
|
||||
if (isDefender) flags |= DEFENDER;
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -179,6 +191,10 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
|
||||
builder.append(" default=").append(defaultValue);
|
||||
}
|
||||
|
||||
if (isDefender()) {
|
||||
builder.append(" default {}");
|
||||
}
|
||||
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import java.io.IOException;
|
||||
* @author max
|
||||
*/
|
||||
public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileStub> {
|
||||
public static final int STUB_VERSION = 9;
|
||||
public static final int STUB_VERSION = 10;
|
||||
|
||||
public JavaFileElementType() {
|
||||
super("java.FILE", JavaLanguage.INSTANCE);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -99,7 +99,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
|
||||
i == JavaElementType.THIS_EXPRESSION ||
|
||||
i == JavaElementType.SUPER_EXPRESSION ||
|
||||
i == JavaDocElementType.DOC_METHOD_OR_FIELD_REF ||
|
||||
i == JavaDocTokenType.DOC_TAG_VALUE_TOKEN ||
|
||||
i == JavaDocElementType.DOC_TAG_VALUE_ELEMENT ||
|
||||
i == JavaElementType.REFERENCE_PARAMETER_LIST ||
|
||||
i == JavaElementType.ANNOTATION) {
|
||||
if (isQualified()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiAnnotationImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -151,7 +152,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement<PsiModifierListStub>
|
||||
return false;
|
||||
}
|
||||
if (type == JavaTokenType.ABSTRACT_KEYWORD) {
|
||||
return true;
|
||||
return !PsiUtil.isExtensionMethod((PsiMethod)parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -21,6 +21,7 @@ import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,7 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class CorePsiDocTagValueImpl extends CompositePsiElement implements PsiDocTagValue {
|
||||
public CorePsiDocTagValueImpl() {
|
||||
super(JavaDocTokenType.DOC_TAG_VALUE_TOKEN);
|
||||
super(JavaDocElementType.DOC_TAG_VALUE_ELEMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +48,7 @@ public class CorePsiDocTagValueImpl extends CompositePsiElement implements PsiDo
|
||||
if (child.getElementType() == JavaDocTokenType.DOC_TAG_VALUE_COMMA) {
|
||||
return ChildRole.COMMA;
|
||||
}
|
||||
|
||||
return super.getChildRole(child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,11 +18,7 @@ package com.intellij.psi.impl.source.javadoc;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.Factory;
|
||||
import com.intellij.psi.impl.source.tree.LeafElement;
|
||||
import com.intellij.psi.impl.source.tree.SharedImplUtil;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
@@ -43,9 +39,8 @@ import java.util.Set;
|
||||
* @author mike
|
||||
*/
|
||||
public class PsiDocParamRef extends CompositePsiElement implements PsiDocTagValue {
|
||||
|
||||
public PsiDocParamRef() {
|
||||
super(Constants.DOC_PARAMETER_REF);
|
||||
super(JavaDocElementType.DOC_PARAMETER_REF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
@@ -37,9 +33,10 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Constants {
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(
|
||||
JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF,
|
||||
DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER);
|
||||
private static final TokenSet TAG_VALUE_BIT_SET = TokenSet.create(
|
||||
DOC_TAG_VALUE_ELEMENT, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF);
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.orSet(TAG_VALUE_BIT_SET, TokenSet.create(
|
||||
DOC_TAG_VALUE_TOKEN, JAVA_CODE_REFERENCE, DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER));
|
||||
|
||||
public PsiDocTagImpl() {
|
||||
super(DOC_TAG);
|
||||
@@ -47,17 +44,17 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
|
||||
@Override
|
||||
public PsiDocComment getContainingComment() {
|
||||
return (PsiDocComment)SourceTreeToPsiMap.treeElementToPsi(getTreeParent());
|
||||
return (PsiDocComment)getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getNameElement() {
|
||||
return findChildByRoleAsPsiElement(ChildRole.DOC_TAG_NAME);
|
||||
return findPsiChildByType(DOC_TAG_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiDocTagValue getValueElement() {
|
||||
return (PsiDocTagValue)findChildByRoleAsPsiElement(ChildRole.DOC_TAG_VALUE);
|
||||
return (PsiDocTagValue)findPsiChildByType(TAG_VALUE_BIT_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,6 +62,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
return getChildrenAsPsiElements(VALUE_BIT_SET, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
if (getNameElement() == null) return "";
|
||||
@@ -79,7 +77,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
|
||||
@Override
|
||||
public int getChildRole(ASTNode child) {
|
||||
assert (child.getTreeParent() == this);
|
||||
assert child.getTreeParent() == this : child.getTreeParent();
|
||||
IElementType i = child.getElementType();
|
||||
if (i == DOC_TAG_NAME) {
|
||||
return ChildRole.DOC_TAG_NAME;
|
||||
@@ -90,10 +88,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
else if (i == DOC_COMMENT_LEADING_ASTERISKS) {
|
||||
return ChildRole.DOC_COMMENT_ASTERISKS;
|
||||
}
|
||||
else if (i == DOC_TAG_VALUE_TOKEN) {
|
||||
return ChildRole.DOC_TAG_VALUE;
|
||||
}
|
||||
else if (i == DOC_METHOD_OR_FIELD_REF || i == DOC_PARAMETER_REF) {
|
||||
else if (TAG_VALUE_BIT_SET.contains(i)) {
|
||||
return ChildRole.DOC_TAG_VALUE;
|
||||
}
|
||||
else {
|
||||
@@ -104,7 +99,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] getReferences() {
|
||||
return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiDocTag.class);
|
||||
return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-15
@@ -13,10 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
@@ -36,11 +35,10 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlineDocTag, Constants {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiInlineDocTagImpl");
|
||||
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(
|
||||
JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF, DOC_COMMENT_DATA, DOC_INLINE_TAG,
|
||||
DOC_REFERENCE_HOLDER, WHITE_SPACE, DOC_COMMENT_BAD_CHARACTER);
|
||||
private static final TokenSet TAG_VALUE_BIT_SET = TokenSet.create(
|
||||
DOC_TAG_VALUE_ELEMENT, DOC_METHOD_OR_FIELD_REF);
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.orSet(TAG_VALUE_BIT_SET, TokenSet.create(
|
||||
JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER, WHITE_SPACE, DOC_COMMENT_BAD_CHARACTER));
|
||||
|
||||
public PsiInlineDocTagImpl() {
|
||||
super(DOC_INLINE_TAG);
|
||||
@@ -57,7 +55,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
|
||||
@Override
|
||||
public PsiElement getNameElement() {
|
||||
return findChildByRoleAsPsiElement(ChildRole.DOC_TAG_NAME);
|
||||
return findPsiChildByType(DOC_TAG_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +65,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
|
||||
@Override
|
||||
public PsiDocTagValue getValueElement() {
|
||||
return (PsiDocTagValue)findChildByRoleAsPsiElement(ChildRole.DOC_TAG_VALUE);
|
||||
return (PsiDocTagValue)findPsiChildByType(TAG_VALUE_BIT_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +77,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
|
||||
@Override
|
||||
public int getChildRole(ASTNode child) {
|
||||
LOG.assertTrue(child.getTreeParent() == this);
|
||||
assert child.getTreeParent() == this : child.getTreeParent();
|
||||
IElementType i = child.getElementType();
|
||||
if (i == DOC_TAG_NAME) {
|
||||
return ChildRole.DOC_TAG_NAME;
|
||||
@@ -93,10 +91,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
else if (i == DOC_INLINE_TAG_END) {
|
||||
return ChildRole.DOC_INLINE_TAG_END;
|
||||
}
|
||||
else if (i == DOC_TAG_VALUE_TOKEN) {
|
||||
return ChildRole.DOC_TAG_VALUE;
|
||||
}
|
||||
else if (i == DOC_METHOD_OR_FIELD_REF) {
|
||||
else if (TAG_VALUE_BIT_SET.contains(i)) {
|
||||
return ChildRole.DOC_TAG_VALUE;
|
||||
}
|
||||
else {
|
||||
@@ -124,4 +119,4 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
PsiImplUtil.setName(getNameElement(), name);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,6 +49,7 @@ public class CoreJavaASTFactory extends ASTFactory implements Constants {
|
||||
return new PsiJavaTokenImpl(type, text);
|
||||
}
|
||||
else if (type instanceof IJavaDocElementType) {
|
||||
assert type != DOC_TAG_VALUE_ELEMENT;
|
||||
return new PsiDocTokenImpl(type, text);
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ public class CoreJavaASTFactory extends ASTFactory implements Constants {
|
||||
|
||||
@Override
|
||||
public CompositeElement createComposite(IElementType type) {
|
||||
if (type == DOC_TAG_VALUE_TOKEN) {
|
||||
if (type == DOC_TAG_VALUE_ELEMENT) {
|
||||
return new CorePsiDocTagValueImpl();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import com.intellij.psi.impl.source.javadoc.PsiDocCommentImpl;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocTagImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiInlineDocTagImpl;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiInlineDocTagImpl;
|
||||
import com.intellij.psi.tree.*;
|
||||
import com.intellij.psi.tree.java.IJavaDocElementType;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
@@ -70,6 +70,7 @@ public interface JavaDocElementType {
|
||||
IElementType DOC_INLINE_TAG = new JavaDocCompositeElementType("DOC_INLINE_TAG", PsiInlineDocTagImpl.class);
|
||||
IElementType DOC_METHOD_OR_FIELD_REF = new JavaDocCompositeElementType("DOC_METHOD_OR_FIELD_REF", PsiDocMethodOrFieldRef.class);
|
||||
IElementType DOC_PARAMETER_REF = new JavaDocCompositeElementType("DOC_PARAMETER_REF", PsiDocParamRef.class);
|
||||
IElementType DOC_TAG_VALUE_ELEMENT = new IJavaDocElementType("DOC_TAG_VALUE_ELEMENT");
|
||||
|
||||
ILazyParseableElementType DOC_REFERENCE_HOLDER = new JavaDocLazyElementType("DOC_REFERENCE_HOLDER") {
|
||||
private final JavaParserUtil.ParserWrapper myParser = new JavaParserUtil.ParserWrapper() {
|
||||
@@ -135,6 +136,6 @@ public interface JavaDocElementType {
|
||||
};
|
||||
|
||||
TokenSet ALL_JAVADOC_ELEMENTS = TokenSet.create(
|
||||
DOC_TAG, DOC_INLINE_TAG, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF, DOC_REFERENCE_HOLDER, DOC_TYPE_HOLDER, DOC_COMMENT
|
||||
);
|
||||
DOC_TAG, DOC_INLINE_TAG, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF, DOC_TAG_VALUE_ELEMENT,
|
||||
DOC_REFERENCE_HOLDER, DOC_TYPE_HOLDER, DOC_COMMENT);
|
||||
}
|
||||
|
||||
@@ -349,6 +349,7 @@ feature.static.imports=Static imports
|
||||
feature.for.each=For-each loops
|
||||
feature.varargs=Variable arity methods
|
||||
feature.diamond.types=Diamond types
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.multi.catch=Multi-catches
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.extension.methods=Extension methods
|
||||
insufficient.language.level={0} are not supported at this language level
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Bar {
|
||||
{
|
||||
Koo<String> hs = new Ko<caret><StringX>();
|
||||
}
|
||||
}
|
||||
class Koo<X> {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Bar {
|
||||
{
|
||||
Koo<String> hs = new Koo<String>()<caret>;
|
||||
}
|
||||
}
|
||||
class Koo<X> {}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Util {
|
||||
void foo(int reaction, boolean rezet) {
|
||||
re<caret>
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
String s = Util.se<caret>
|
||||
}
|
||||
|
||||
class Util {
|
||||
public static final String serial = "serialVersionUID";
|
||||
|
||||
public static Runnable superExpressionInIllegalContext() {}
|
||||
|
||||
}
|
||||
+22
-9
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// illegal method calls
|
||||
|
||||
class A {
|
||||
@@ -48,14 +64,12 @@ class CX {
|
||||
|
||||
|
||||
class c {
|
||||
c() {
|
||||
c() {}
|
||||
|
||||
}
|
||||
class inner {
|
||||
class ininner {}
|
||||
}
|
||||
|
||||
|
||||
static void f() {
|
||||
<error descr="'c.this' cannot be referenced from a static context">new inner()</error>;
|
||||
}
|
||||
@@ -88,21 +102,20 @@ class DCC {
|
||||
}
|
||||
|
||||
public DCC(int i, int z) {
|
||||
<error descr="Method call expected">DCC(i)</error>;
|
||||
<error descr="Method call expected">DCC(i)</error>;
|
||||
}
|
||||
void f() {
|
||||
<error descr="Method call expected">DCC(1)</error>;
|
||||
new DCC(1);
|
||||
}
|
||||
{
|
||||
<error descr="Qualifier must be an expression">java</error>.toString();
|
||||
}
|
||||
|
||||
{
|
||||
<error descr="Qualifier must be an expression">java</error>.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class ThisExpression {
|
||||
static String foo() {
|
||||
System.out.println(<error descr="'ThisExpression.this' cannot be referenced from a static context">this</error>);
|
||||
return <error descr="'ThisExpression.this' cannot be referenced from a static context">this</error>.toString();
|
||||
return <error descr="'ThisExpression.super' cannot be referenced from a static context">super</error>.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -17,3 +17,16 @@ class b extends A {
|
||||
static class c {}
|
||||
}
|
||||
|
||||
|
||||
class WithAnonym {
|
||||
interface I {
|
||||
}
|
||||
class Inner{}
|
||||
}
|
||||
|
||||
class WithAnonymInheritor extends WithAnonym {
|
||||
{
|
||||
<error descr="Anonymous class implements interface; cannot have qualifier for new">this.new I() {}</error>;
|
||||
this.new Inner() {};
|
||||
}
|
||||
}
|
||||
+4
@@ -38,4 +38,8 @@ class UnsupportedFeatures {
|
||||
|
||||
try <error descr="Try-with-resources are not supported at this language level">(Reader r = new FileReader("/dev/null"))</error> { }
|
||||
}
|
||||
|
||||
interface I {
|
||||
<error descr="Extension methods are not supported at this language level">void m() default { }</error>
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class C {
|
||||
interface I {
|
||||
void m() default { }
|
||||
}
|
||||
|
||||
void test() {
|
||||
new I(){}.m();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
abstract class A {
|
||||
public abstract D foo();
|
||||
}
|
||||
|
||||
interface B {
|
||||
F foo();
|
||||
}
|
||||
|
||||
class C extends A implements B {
|
||||
public F foo() {
|
||||
<selection>return null; //To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
|
||||
class D {}
|
||||
class F extends D {}
|
||||
@@ -0,0 +1,9 @@
|
||||
interface Function<S> {
|
||||
void fun(Function<S> function);
|
||||
}
|
||||
|
||||
class Bar extends Function<String>{
|
||||
public void fun(Function<String> function) {
|
||||
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
abstract class A {
|
||||
public abstract D foo();
|
||||
}
|
||||
|
||||
interface B {
|
||||
F foo();
|
||||
}
|
||||
|
||||
class C extends A implements B {
|
||||
<caret>
|
||||
}
|
||||
|
||||
class D {}
|
||||
class F extends D {}
|
||||
@@ -0,0 +1,7 @@
|
||||
interface Function<S> {
|
||||
void fun(Function<S> function);
|
||||
}
|
||||
|
||||
class Bar extends Function<String>{
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Foo {
|
||||
public void foo() {
|
||||
final boolean flag = true;
|
||||
|
||||
bar(<warning descr="Condition 'flag' is always 'true'">flag</warning> ? "a" : "b",
|
||||
<warning descr="Condition 'flag' is always 'true'">flag</warning> ? new String[]{"aa"} : new String[]{"bb"}
|
||||
);
|
||||
}
|
||||
|
||||
void bar(String b, String[] a) {
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ PsiJavaFile:Exception0.java
|
||||
PsiDocTag:@throws
|
||||
PsiDocToken:DOC_TAG_NAME('@throws')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_REFERENCE_HOLDER)
|
||||
PsiJavaCodeReferenceElement:java.lang.Exception
|
||||
PsiJavaCodeReferenceElement:java.lang
|
||||
|
||||
@@ -15,7 +15,7 @@ PsiJavaFile:InlineTag1.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('somefunc')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
|
||||
@@ -15,7 +15,7 @@ PsiJavaFile:InlineTag2.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('somefunc')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
|
||||
@@ -15,7 +15,7 @@ PsiJavaFile:InlineTag3.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('somefunc')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:String
|
||||
PsiJavaCodeReferenceElement:String
|
||||
|
||||
@@ -30,7 +30,7 @@ PsiJavaFile:LinkPlainTag1.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:java.lang.Object
|
||||
PsiJavaCodeReferenceElement:java.lang.Object
|
||||
|
||||
@@ -10,7 +10,7 @@ PsiJavaFile:LinkPlainTag2.java
|
||||
PsiDocTag:@linkplain
|
||||
PsiDocToken:DOC_TAG_NAME('@linkplain')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('java.lang.String')
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
|
||||
@@ -30,7 +30,7 @@ PsiJavaFile:LinkTag1.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:java.lang.Object
|
||||
PsiJavaCodeReferenceElement:java.lang.Object
|
||||
|
||||
@@ -10,7 +10,7 @@ PsiJavaFile:LinkTag2.java
|
||||
PsiDocTag:@link
|
||||
PsiDocToken:DOC_TAG_NAME('@link')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('java.lang.String')
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
|
||||
@@ -17,7 +17,7 @@ PsiJavaFile:LinkTag3.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('foo')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiDocToken:DOC_INLINE_TAG_END('}')
|
||||
|
||||
@@ -16,7 +16,7 @@ PsiJavaFile:LinkTag4.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('foo')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiDocToken:DOC_INLINE_TAG_END('}')
|
||||
|
||||
@@ -15,7 +15,7 @@ PsiJavaFile:LinkTag5.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('foo')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiDocToken:DOC_INLINE_TAG_END('}')
|
||||
|
||||
@@ -15,7 +15,7 @@ PsiJavaFile:LinkTag6.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('foo')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiDocToken:DOC_INLINE_TAG_END('}')
|
||||
|
||||
@@ -29,7 +29,7 @@ PsiJavaFile:SeeTag10.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:java.lang.Object
|
||||
PsiJavaCodeReferenceElement:java.lang.Object
|
||||
|
||||
@@ -29,7 +29,7 @@ PsiJavaFile:SeeTag11.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('wait')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
|
||||
@@ -14,7 +14,7 @@ PsiJavaFile:SeeTag12.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('wait')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
<empty list>
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
|
||||
@@ -29,7 +29,7 @@ PsiJavaFile:SeeTag14.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('append')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:char[]
|
||||
PsiTypeElement:char
|
||||
|
||||
@@ -29,7 +29,7 @@ PsiJavaFile:SeeTag15.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('append')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:java.lang.Object
|
||||
PsiJavaCodeReferenceElement:java.lang.Object
|
||||
|
||||
@@ -19,7 +19,7 @@ PsiJavaFile:SeeTag16.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:int
|
||||
PsiKeyword:int('int')
|
||||
|
||||
@@ -19,7 +19,7 @@ PsiJavaFile:SeeTag3.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('equals')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:Object
|
||||
PsiJavaCodeReferenceElement:Object
|
||||
|
||||
@@ -29,7 +29,7 @@ PsiJavaFile:SeeTag5.java
|
||||
PsiDocToken:DOC_TAG_VALUE_SHARP_TOKEN('#')
|
||||
PsiDocToken:DOC_TAG_VALUE_TOKEN('wait')
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiElement(DOC_TYPE_HOLDER)
|
||||
PsiTypeElement:long
|
||||
PsiKeyword:long('long')
|
||||
|
||||
@@ -15,16 +15,16 @@ PsiJavaFile:SeeTag9.java
|
||||
PsiIdentifier:equals('equals')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_LPAREN('(')
|
||||
PsiElement(DOC_REFERENCE_HOLDER)
|
||||
PsiKeyword:long('long')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(DOC_REFERENCE_HOLDER)
|
||||
PsiKeyword:long('long')
|
||||
PsiElement(DOC_TAG_VALUE_TOKEN)
|
||||
PsiElement(DOC_TAG_VALUE_ELEMENT)
|
||||
PsiDocToken:DOC_TAG_VALUE_RPAREN(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiDocToken:DOC_COMMENT_END('*/')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user