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:
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Guava">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-11.0.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-12.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/guava-11.0.1-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/guava-12.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -505,7 +505,7 @@ def layout_core(String home, String target) {
|
||||
}
|
||||
|
||||
fileset(dir: "$home/lib") {
|
||||
include(name: "guava-11.0.1.jar")
|
||||
include(name: "guava-12.0.jar")
|
||||
include(name: "picocontainer.jar")
|
||||
include(name: "trove4j.jar")
|
||||
include(name: "asm.jar")
|
||||
@@ -537,7 +537,7 @@ def layout_core_upsource(String home, String target) {
|
||||
}
|
||||
|
||||
fileset(dir: "$home/lib") {
|
||||
include(name: "guava-11.0.1.jar")
|
||||
include(name: "guava-12.0.jar")
|
||||
include(name: "picocontainer.jar")
|
||||
include(name: "trove4j.jar")
|
||||
include(name: "asm.jar")
|
||||
|
||||
+1
-1
@@ -858,7 +858,7 @@ 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");
|
||||
container.getDelegeeClientProperties().put(ourBorderFactoryClientProperty, StringDescriptor.create("com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"));
|
||||
}
|
||||
|
||||
Type borderFactoryType = ourBorderFactoryType;
|
||||
|
||||
@@ -19,12 +19,12 @@ import com.intellij.ProjectTopics;
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.server.impl.CompileServerClasspathManager;
|
||||
import com.intellij.execution.ExecutionAdapter;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.process.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
@@ -114,9 +114,11 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
};
|
||||
private final SequentialTaskExecutor myEventsProcessor = new SequentialTaskExecutor(myPooledThreadExecutor);
|
||||
|
||||
private final Map<String, ProjectData> myProjectDataMap = Collections.synchronizedMap(new HashMap<String, ProjectData>());
|
||||
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
private final AtomicBoolean myAutoMakeInProgress = new AtomicBoolean(false);
|
||||
|
||||
private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("build-manager");
|
||||
private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
|
||||
private int myListenPort = -1;
|
||||
@@ -137,8 +139,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
projectManager.addProjectManagerListener(new ProjectWatcher());
|
||||
final MessageBusConnection conn = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
conn.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
private final AtomicBoolean myAutoMakeInProgress = new AtomicBoolean(false);
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
}
|
||||
@@ -146,44 +146,11 @@ public class BuildManager implements ApplicationComponent{
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
if (shouldTriggerMake(events)) {
|
||||
scheduleMake(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myAutoMakeInProgress.getAndSet(true)) {
|
||||
try {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
runAutoMake();
|
||||
}
|
||||
finally {
|
||||
myAutoMakeInProgress.set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (RejectedExecutionException ignored) {
|
||||
// we were shut down
|
||||
}
|
||||
}
|
||||
else {
|
||||
scheduleMake(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
scheduleAutoMake();
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleMake(Runnable runnable) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(runnable, MAKE_TRIGGER_DELAY);
|
||||
}
|
||||
|
||||
private boolean shouldTriggerMake(List<? extends VFileEvent> events) {
|
||||
if (!CompilerWorkspaceConfiguration.useServerlessOutOfProcessBuild()) {
|
||||
return false;
|
||||
}
|
||||
for (VFileEvent event : events) {
|
||||
if (event.isFromRefresh() || event.getRequestor() instanceof SavingRequestor) {
|
||||
return true;
|
||||
@@ -265,10 +232,46 @@ public class BuildManager implements ApplicationComponent{
|
||||
return vFile != null ? vFile.getPath() : null;
|
||||
}
|
||||
|
||||
private void runAutoMake() {
|
||||
private void scheduleAutoMake() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
if (CompilerWorkspaceConfiguration.useServerlessOutOfProcessBuild()) {
|
||||
addMakeRequest(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myAutoMakeInProgress.getAndSet(true)) {
|
||||
try {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
runAutoMake();
|
||||
}
|
||||
finally {
|
||||
myAutoMakeInProgress.set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (RejectedExecutionException ignored) {
|
||||
// we were shut down
|
||||
}
|
||||
}
|
||||
else {
|
||||
addMakeRequest(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void addMakeRequest(Runnable runnable) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(runnable, MAKE_TRIGGER_DELAY);
|
||||
}
|
||||
|
||||
private void runAutoMake() {
|
||||
final Project[] openProjects = myProjectManager.getOpenProjects();
|
||||
if (openProjects.length > 0) {
|
||||
final List<RequestFuture> futures = new ArrayList<RequestFuture>();
|
||||
@@ -412,7 +415,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
// re-translate builder's output to idea.log
|
||||
final String text = event.getText();
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
if (!StringUtil.isEmptyOrSpaces(text)) {
|
||||
LOG.info("BUILDER_PROCESS [" + outputType.toString() + "]: " + text.trim());
|
||||
if (stdErrOutput.length() < 1024 && ProcessOutputTypes.STDERR.equals(outputType)) {
|
||||
stdErrOutput.append(text);
|
||||
@@ -819,6 +822,12 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
});
|
||||
conn.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionAdapter() {
|
||||
@Override
|
||||
public void processTerminated(@NotNull RunProfile runProfile, @NotNull ProcessHandler handler) {
|
||||
scheduleAutoMake();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-7
@@ -32,8 +32,10 @@ import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.impl.actions.EditBreakpointActionHandler;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -49,7 +51,7 @@ import java.awt.*;
|
||||
*/
|
||||
public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler {
|
||||
@Override
|
||||
protected void doShowPopup(Project project, final EditorGutterComponentEx gutterComponent, final Point whereToShow, Object breakpoint) {
|
||||
protected void doShowPopup(final Project project, final EditorGutterComponentEx gutterComponent, final Point whereToShow, Object breakpoint) {
|
||||
if (!(breakpoint instanceof BreakpointWithHighlighter)) return;
|
||||
|
||||
final BreakpointWithHighlighter javaBreakpoint = (BreakpointWithHighlighter)breakpoint;
|
||||
@@ -88,13 +90,16 @@ public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler
|
||||
final Runnable showMoreOptions = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
propertiesPanel.setMoreOptionsVisible(true);
|
||||
final Balloon newBalloon = DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent, null);
|
||||
newBalloon.addListener(saveOnClose);
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BreakpointsMasterDetailPopupFactory.
|
||||
getInstance(project).createPopup(javaBreakpoint).showCenteredInCurrentWindow(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent,
|
||||
propertiesPanel.isMoreOptionsVisible() ? null : showMoreOptions);
|
||||
final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(project, mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions);
|
||||
balloon.addListener(saveOnClose);
|
||||
|
||||
propertiesPanel.setDelegate(new BreakpointPropertiesPanel.Delegate() {
|
||||
@@ -103,7 +108,7 @@ public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler
|
||||
propertiesPanel.setActionsPanelVisible(true);
|
||||
balloon.hide();
|
||||
final Balloon newBalloon =
|
||||
DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions);
|
||||
DebuggerUIUtil.showBreakpointEditor(project, mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions);
|
||||
newBalloon.addListener(saveOnClose);
|
||||
}
|
||||
});
|
||||
|
||||
+8
-7
@@ -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.
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.intellij.debugger.engine.evaluation.expression;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
@@ -160,7 +161,7 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
final PsiType unboxedLType = PsiPrimitiveType.getUnboxedType(lType);
|
||||
|
||||
if (unboxedLType != null) {
|
||||
if (rType instanceof PsiPrimitiveType && !PsiPrimitiveType.NULL.equals(rType)) {
|
||||
if (rType instanceof PsiPrimitiveType && !PsiType.NULL.equals(rType)) {
|
||||
if (!rType.equals(unboxedLType)) {
|
||||
rEvaluator = new TypeCastEvaluator(rEvaluator, unboxedLType.getCanonicalText(), true);
|
||||
}
|
||||
@@ -175,7 +176,7 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
}
|
||||
final PsiPrimitiveType unboxedRType = PsiPrimitiveType.getUnboxedType(rType);
|
||||
final PsiType _rType = unboxedRType != null? unboxedRType : rType;
|
||||
if (_rType instanceof PsiPrimitiveType && !PsiPrimitiveType.NULL.equals(_rType)) {
|
||||
if (_rType instanceof PsiPrimitiveType && !PsiType.NULL.equals(_rType)) {
|
||||
if (!lType.equals(_rType)) {
|
||||
rEvaluator = new TypeCastEvaluator(rEvaluator, lType.getCanonicalText(), true);
|
||||
}
|
||||
@@ -988,9 +989,9 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
|
||||
@Override
|
||||
public void visitLiteralExpression(PsiLiteralExpression expression) {
|
||||
final String parsingError = HighlightUtil.getLiteralExpressionParsingError(expression);
|
||||
final HighlightInfo parsingError = HighlightUtil.checkLiteralExpressionParsingError(expression);
|
||||
if (parsingError != null) {
|
||||
throwEvaluateException(parsingError);
|
||||
throwEvaluateException(parsingError.description);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1219,9 +1220,9 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
myResult = new ArrayInitializerEvaluator(evaluators);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiClass getOuterClass(PsiClass aClass) {
|
||||
if(aClass == null) return null;
|
||||
return PsiTreeUtil.getContextOfType(aClass, PsiClass.class, true);
|
||||
return aClass == null ? null : PsiTreeUtil.getContextOfType(aClass, PsiClass.class, true);
|
||||
}
|
||||
|
||||
private PsiClass getContainingClass(PsiVariable variable) {
|
||||
|
||||
@@ -214,8 +214,10 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideBreakpointsGroupingRules(Collection<XBreakpointGroupingRule> rules) {
|
||||
public void createBreakpointsGroupingRules(Collection<XBreakpointGroupingRule> rules) {
|
||||
rules.add(new XBreakpointGroupingByCategoryRule());
|
||||
rules.add(new XBreakpointGroupingByPackageRule());
|
||||
rules.add(new XBreakpointGroupingByClassRule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.DebuggerBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class XBreakpointClassGroup extends XBreakpointGroup {
|
||||
private static final String DEFAULT_PACKAGE_NAME = DebuggerBundle.message("default.package.name");
|
||||
|
||||
private String myPackageName;
|
||||
private String myClassName;
|
||||
|
||||
public XBreakpointClassGroup(@Nullable String packageName, String className) {
|
||||
myPackageName = packageName != null ? packageName : DEFAULT_PACKAGE_NAME;
|
||||
myClassName = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean isOpen) {
|
||||
return PlatformIcons.CLASS_ICON;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClassName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPackageName() {
|
||||
return myPackageName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getClassName() {
|
||||
return myClassName;
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -22,18 +22,16 @@ 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 boolean isAlwaysEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XBreakpointCategoryGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointCategoryGroup> groups) {
|
||||
if (b instanceof Breakpoint) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
class XBreakpointGroupingByClassRule<B> extends XBreakpointGroupingRule<B, XBreakpointClassGroup> {
|
||||
XBreakpointGroupingByClassRule() {
|
||||
super("XBreakpointGroupingByClassRule", "Group by Class");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XBreakpointClassGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointClassGroup> groups) {
|
||||
if (b instanceof Breakpoint) {
|
||||
final Breakpoint breakpoint = (Breakpoint)b;
|
||||
String className = breakpoint.getShortClassName();
|
||||
String packageName = breakpoint.getPackageName();
|
||||
if (className == null) {
|
||||
return null;
|
||||
}
|
||||
for (XBreakpointClassGroup group : groups) {
|
||||
if (group.getClassName().equals(className) && group.getPackageName().equals(packageName)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return new XBreakpointClassGroup(packageName, className);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.BreakpointWithHighlighter;
|
||||
import com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class XBreakpointGroupingByPackageRule<B> extends XBreakpointGroupingRule<B, XBreakpointPackageGroup> {
|
||||
|
||||
protected XBreakpointGroupingByPackageRule() {
|
||||
super("XBreakpointGroupingByPackageRule", "Group by package");
|
||||
}
|
||||
|
||||
@Override
|
||||
public XBreakpointPackageGroup getGroup(@NotNull B breakpoint, @NotNull Collection<XBreakpointPackageGroup> groups) {
|
||||
String packageName = null;
|
||||
if (breakpoint instanceof BreakpointWithHighlighter) {
|
||||
packageName = ((BreakpointWithHighlighter)breakpoint).getPackageName();
|
||||
}
|
||||
else if (breakpoint instanceof ExceptionBreakpoint) {
|
||||
packageName = ((ExceptionBreakpoint)breakpoint).getPackageName();
|
||||
}
|
||||
if (packageName == null) {
|
||||
return null;
|
||||
}
|
||||
for (XBreakpointPackageGroup group : groups) {
|
||||
if (StringUtil.equals(group.getPackageName(), packageName)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return new XBreakpointPackageGroup(packageName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.DebuggerBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class XBreakpointPackageGroup extends XBreakpointGroup {
|
||||
private static final String DEFAULT_PACKAGE_NAME = DebuggerBundle.message("default.package.name");
|
||||
|
||||
private String myPackageName;
|
||||
|
||||
public XBreakpointPackageGroup(String packageName) {
|
||||
myPackageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean isOpen) {
|
||||
return PlatformIcons.PACKAGE_ICON;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
String packageName = getPackageName();
|
||||
return StringUtil.isEmpty(packageName) ? DEFAULT_PACKAGE_NAME : packageName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPackageName() {
|
||||
return myPackageName;
|
||||
}
|
||||
}
|
||||
@@ -679,7 +679,7 @@ public class BreakpointTree extends CheckboxTree {
|
||||
if (!(descriptor instanceof BreakpointDescriptor)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
final Breakpoint breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
|
||||
final String packageName;
|
||||
if (breakpoint instanceof ExceptionBreakpoint) {
|
||||
|
||||
+1
@@ -522,6 +522,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
if (!highlighter.isValid()) {
|
||||
return null;
|
||||
}
|
||||
highlighter.putUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY, Boolean.TRUE);
|
||||
highlighter.setErrorStripeTooltip(DebuggerBundle.message("breakpoint.tooltip.text", lineIndex + 1));
|
||||
return highlighter;
|
||||
}
|
||||
|
||||
@@ -334,19 +334,36 @@ public abstract class DebuggerUtils {
|
||||
return getSuperType(subType, superType) != null;
|
||||
}
|
||||
|
||||
public static PsiClass findClass(String className, Project project, final GlobalSearchScope scope) {
|
||||
@Nullable
|
||||
public static PsiClass findClass(final String className, Project project, final GlobalSearchScope scope) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(psiManager.getProject());
|
||||
if (getArrayClass(className) != null) {
|
||||
return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().getArrayClass(LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel());
|
||||
return javaPsiFacade.getElementFactory().getArrayClass(LanguageLevelProjectExtension.getInstance(psiManager.getProject()).getLanguageLevel());
|
||||
}
|
||||
if(project.isDefault()) {
|
||||
return null;
|
||||
}
|
||||
final String _className = className.replace('$', '.');
|
||||
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(_className, scope);
|
||||
if (aClass == null && scope != GlobalSearchScope.allScope(project)) {
|
||||
return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(_className, GlobalSearchScope.allScope(project));
|
||||
PsiClass aClass = javaPsiFacade.findClass(_className, scope);
|
||||
if (aClass == null) {
|
||||
if (!_className.equals(className)) {
|
||||
// try original name if it differs from the normalized name
|
||||
aClass = javaPsiFacade.findClass(className, scope);
|
||||
}
|
||||
}
|
||||
if (aClass == null) {
|
||||
final GlobalSearchScope globalScope = GlobalSearchScope.allScope(project);
|
||||
if (!globalScope.equals(scope)) {
|
||||
aClass = javaPsiFacade.findClass(_className, globalScope);
|
||||
if (aClass == null) {
|
||||
if (!_className.equals(className)) {
|
||||
// try original name with global scope if the original differs from the normalized name
|
||||
aClass = javaPsiFacade.findClass(className, globalScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return aClass;
|
||||
}
|
||||
|
||||
+63
-14
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.CheckBoxList;
|
||||
import com.intellij.ui.CheckBoxListListener;
|
||||
import com.intellij.ui.CollectionListModel;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -47,6 +48,7 @@ import java.util.List;
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
private static enum AdditionalDownloadType {SOURCES, DOCUMENTATION}
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.libraries.DownloadingOptionsDialog");
|
||||
private JPanel myPanel;
|
||||
private CheckBoxList myFilesList;
|
||||
@@ -110,32 +112,79 @@ public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
myCopyDownloadedFilesToLabel.setLabelFor(myDirectoryField);
|
||||
myDirectoryField.setText(FileUtil.toSystemDependentName(settings.getDirectoryForDownloadedLibrariesPath()));
|
||||
|
||||
//todo[nik] show when downloading sources/javadocs will be supported
|
||||
myDownloadSourcesCheckBox.setVisible(false);
|
||||
myDownloadJavadocsCheckBox.setVisible(false);
|
||||
boolean sourcesCheckboxVisible = false;
|
||||
boolean javadocCheckboxVisible = false;
|
||||
for (FrameworkLibraryVersion version : versions) {
|
||||
sourcesCheckboxVisible |= haveAdditionalDownloads(version.getFiles(), AdditionalDownloadType.SOURCES);
|
||||
javadocCheckboxVisible |= haveAdditionalDownloads(version.getFiles(), AdditionalDownloadType.DOCUMENTATION);
|
||||
}
|
||||
myDownloadSourcesCheckBox.setVisible(sourcesCheckboxVisible);
|
||||
myDownloadJavadocsCheckBox.setVisible(javadocCheckboxVisible);
|
||||
myFilesList.setCheckBoxListListener(new CheckBoxListListener() {
|
||||
@Override
|
||||
public void checkBoxSelectionChanged(int index, boolean value) {
|
||||
updateSourcesAndJavadocCheckboxes();
|
||||
}
|
||||
});
|
||||
|
||||
updateSourcesAndJavadocCheckboxes();
|
||||
myDownloadSourcesCheckBox.setSelected(settings.isDownloadSources());
|
||||
myDownloadJavadocsCheckBox.setSelected(settings.isDownloadJavaDocs());
|
||||
init();
|
||||
}
|
||||
|
||||
private void onVersionChanged(final @Nullable List<? extends DownloadableFileDescription> selected) {
|
||||
private void updateSourcesAndJavadocCheckboxes() {
|
||||
final FrameworkLibraryVersion version = getSelectedVersion();
|
||||
boolean sourcesCheckboxEnabled;
|
||||
boolean javadocCheckboxEnabled;
|
||||
if (version == null) {
|
||||
sourcesCheckboxEnabled = javadocCheckboxEnabled = false;
|
||||
}
|
||||
else {
|
||||
final List<DownloadableLibraryFileDescription> descriptions = getSelectedDownloads(version);
|
||||
sourcesCheckboxEnabled = haveAdditionalDownloads(descriptions, AdditionalDownloadType.SOURCES);
|
||||
javadocCheckboxEnabled = haveAdditionalDownloads(descriptions, AdditionalDownloadType.DOCUMENTATION);
|
||||
}
|
||||
setEnabled(myDownloadSourcesCheckBox, sourcesCheckboxEnabled);
|
||||
setEnabled(myDownloadJavadocsCheckBox, javadocCheckboxEnabled);
|
||||
}
|
||||
|
||||
private static void setEnabled(final JCheckBox checkBox, final boolean enabled) {
|
||||
if (!enabled) {
|
||||
checkBox.setSelected(false);
|
||||
}
|
||||
checkBox.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private static boolean haveAdditionalDownloads(final List<? extends DownloadableLibraryFileDescription> descriptions, AdditionalDownloadType type) {
|
||||
for (DownloadableLibraryFileDescription description : descriptions) {
|
||||
if (type == AdditionalDownloadType.SOURCES && description.getSourcesDescription() != null
|
||||
|| type == AdditionalDownloadType.DOCUMENTATION && description.getDocumentationDescription() != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onVersionChanged(final @Nullable List<? extends DownloadableLibraryFileDescription> selectedFiles) {
|
||||
final FrameworkLibraryVersion version = getSelectedVersion();
|
||||
if (Comparing.equal(myLastSelectedVersion, version)) return;
|
||||
|
||||
if (version != null) {
|
||||
final List<? extends DownloadableFileDescription> downloads = version.getFiles();
|
||||
myFilesList.setModel(new CollectionListModel(
|
||||
ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableFileDescription, JCheckBox>() {
|
||||
final List<? extends DownloadableLibraryFileDescription> downloads = version.getFiles();
|
||||
myFilesList.setModel(new CollectionListModel<JCheckBox>(
|
||||
ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableLibraryFileDescription, JCheckBox>() {
|
||||
@Override
|
||||
public JCheckBox fun(DownloadableFileDescription description) {
|
||||
return new JCheckBox(description.getPresentableFileName(), selected == null || selected.contains(description));
|
||||
public JCheckBox fun(DownloadableLibraryFileDescription description) {
|
||||
final boolean selected = selectedFiles != null ? selectedFiles.contains(description) : !description.isOptional();
|
||||
return new JCheckBox(description.getPresentableFileName(), selected);
|
||||
}
|
||||
})));
|
||||
if (myNameAndLevelPanel != null) {
|
||||
myNameAndLevelPanel.setDefaultName(version.getDefaultLibraryName());
|
||||
}
|
||||
}
|
||||
updateSourcesAndJavadocCheckboxes();
|
||||
myLastSelectedVersion = version;
|
||||
}
|
||||
|
||||
@@ -168,9 +217,9 @@ public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
return dialog.createSettings();
|
||||
}
|
||||
|
||||
private List<DownloadableFileDescription> getSelectedDownloads(FrameworkLibraryVersion version) {
|
||||
List<DownloadableFileDescription> selected = new ArrayList<DownloadableFileDescription>();
|
||||
List<? extends DownloadableFileDescription> downloads = version.getFiles();
|
||||
private List<DownloadableLibraryFileDescription> getSelectedDownloads(FrameworkLibraryVersion version) {
|
||||
List<DownloadableLibraryFileDescription> selected = new ArrayList<DownloadableLibraryFileDescription>();
|
||||
List<? extends DownloadableLibraryFileDescription> downloads = version.getFiles();
|
||||
for (int i = 0; i < downloads.size(); i++) {
|
||||
if (myFilesList.isItemSelected(i)) {
|
||||
selected.add(downloads.get(i));
|
||||
@@ -194,7 +243,7 @@ public class DownloadingOptionsDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
final String path = FileUtil.toSystemIndependentName(myDirectoryField.getText());
|
||||
List<DownloadableFileDescription> selected = getSelectedDownloads(version);
|
||||
List<DownloadableLibraryFileDescription> selected = getSelectedDownloads(version);
|
||||
|
||||
return new LibraryDownloadSettings(version, myLibraryType, path, libraryName, libraryLevel, selected,
|
||||
myDownloadSourcesCheckBox.isSelected(), myDownloadJavadocsCheckBox.isSelected());
|
||||
|
||||
@@ -15,20 +15,28 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.ui.libraries;
|
||||
|
||||
import com.intellij.framework.library.DownloadableLibraryFileDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.util.download.DownloadableFileService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -41,19 +49,19 @@ public class LibraryDownloadSettings {
|
||||
private final boolean myDownloadSources;
|
||||
private final boolean myDownloadJavaDocs;
|
||||
private final LibrariesContainer.LibraryLevel myLibraryLevel;
|
||||
private final List<? extends DownloadableFileDescription> mySelectedDownloads;
|
||||
private final List<? extends DownloadableLibraryFileDescription> mySelectedDownloads;
|
||||
|
||||
public LibraryDownloadSettings(@NotNull FrameworkLibraryVersion libraryVersion,
|
||||
@Nullable DownloadableLibraryType libraryType,
|
||||
final LibrariesContainer.LibraryLevel libraryLevel, final String downloadedLibrariesPath) {
|
||||
this(libraryVersion, libraryType, downloadedLibrariesPath, libraryVersion.getDefaultLibraryName(), libraryLevel,
|
||||
libraryVersion.getFiles(), true, true);
|
||||
getRequiredFiles(libraryVersion.getFiles()), true, true);
|
||||
}
|
||||
|
||||
public LibraryDownloadSettings(@NotNull FrameworkLibraryVersion libraryVersion, @Nullable DownloadableLibraryType libraryType,
|
||||
@NotNull String directoryForDownloadedLibrariesPath, @NotNull String libraryName,
|
||||
@NotNull LibrariesContainer.LibraryLevel libraryLevel,
|
||||
@NotNull List<? extends DownloadableFileDescription> selectedDownloads,
|
||||
@NotNull List<? extends DownloadableLibraryFileDescription> selectedDownloads,
|
||||
boolean downloadSources, boolean downloadJavaDocs) {
|
||||
myVersion = libraryVersion;
|
||||
myLibraryType = libraryType;
|
||||
@@ -65,6 +73,15 @@ public class LibraryDownloadSettings {
|
||||
mySelectedDownloads = selectedDownloads;
|
||||
}
|
||||
|
||||
private static List<? extends DownloadableLibraryFileDescription> getRequiredFiles(List<? extends DownloadableLibraryFileDescription> files) {
|
||||
return ContainerUtil.filter(files, new Condition<DownloadableLibraryFileDescription>() {
|
||||
@Override
|
||||
public boolean value(DownloadableLibraryFileDescription description) {
|
||||
return !description.isOptional();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FrameworkLibraryVersion getVersion() {
|
||||
return myVersion;
|
||||
@@ -86,7 +103,7 @@ public class LibraryDownloadSettings {
|
||||
return myDirectoryForDownloadedLibrariesPath;
|
||||
}
|
||||
|
||||
public List<? extends DownloadableFileDescription> getSelectedDownloads() {
|
||||
public List<? extends DownloadableLibraryFileDescription> getSelectedDownloads() {
|
||||
return mySelectedDownloads;
|
||||
}
|
||||
|
||||
@@ -109,10 +126,26 @@ public class LibraryDownloadSettings {
|
||||
|
||||
@Nullable
|
||||
public NewLibraryEditor download(JComponent parent) {
|
||||
VirtualFile[] files = DownloadableFileService.getInstance().createDownloader(mySelectedDownloads, null, parent, myLibraryName + " Library")
|
||||
final List<DownloadableFileDescription> toDownload = new ArrayList<DownloadableFileDescription>(mySelectedDownloads);
|
||||
Map<DownloadableFileDescription, OrderRootType> rootTypes = new HashMap<DownloadableFileDescription, OrderRootType>();
|
||||
for (DownloadableLibraryFileDescription description : mySelectedDownloads) {
|
||||
final DownloadableFileDescription sources = description.getSourcesDescription();
|
||||
if (myDownloadSources && sources != null) {
|
||||
toDownload.add(sources);
|
||||
rootTypes.put(sources, OrderRootType.SOURCES);
|
||||
}
|
||||
final DownloadableFileDescription docs = description.getDocumentationDescription();
|
||||
if (myDownloadJavaDocs && docs != null) {
|
||||
toDownload.add(docs);
|
||||
rootTypes.put(docs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<VirtualFile,DownloadableFileDescription>> downloaded =
|
||||
DownloadableFileService.getInstance().createDownloader(toDownload, null, parent, myLibraryName + " Library")
|
||||
.toDirectory(myDirectoryForDownloadedLibrariesPath)
|
||||
.download();
|
||||
if (files == null) {
|
||||
.downloadAndReturnWithDescriptions();
|
||||
if (downloaded == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -124,8 +157,9 @@ public class LibraryDownloadSettings {
|
||||
libraryEditor = new NewLibraryEditor();
|
||||
}
|
||||
libraryEditor.setName(myLibraryName);
|
||||
for (VirtualFile file : files) {
|
||||
libraryEditor.addRoot(file, OrderRootType.CLASSES);
|
||||
for (Pair<VirtualFile, DownloadableFileDescription> pair : downloaded) {
|
||||
final OrderRootType rootType = rootTypes.containsKey(pair.getSecond()) ? rootTypes.get(pair.getSecond()) : OrderRootType.CLASSES;
|
||||
libraryEditor.addRoot(pair.getFirst(), rootType);
|
||||
}
|
||||
return libraryEditor;
|
||||
}
|
||||
|
||||
+5
-6
@@ -19,16 +19,16 @@ import com.intellij.facet.impl.ui.libraries.RequiredLibrariesInfo;
|
||||
import com.intellij.facet.ui.libraries.LibraryDownloadInfo;
|
||||
import com.intellij.facet.ui.libraries.LibraryInfo;
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryFileDescription;
|
||||
import com.intellij.framework.library.FrameworkLibraryVersion;
|
||||
import com.intellij.framework.library.impl.DownloadableLibraryDescriptionImpl;
|
||||
import com.intellij.framework.library.impl.DownloadableLibraryFileDescriptionImpl;
|
||||
import com.intellij.framework.library.impl.FrameworkLibraryVersionImpl;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryKind;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||
import com.intellij.util.download.DownloadableFileDescription;
|
||||
import com.intellij.util.download.impl.DownloadableFileDescriptionImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -53,13 +53,12 @@ public class OldCustomLibraryDescription extends CustomLibraryDescriptionBase {
|
||||
myVersions = versions;
|
||||
final List<FrameworkLibraryVersion> libraryVersions = new ArrayList<FrameworkLibraryVersion>();
|
||||
for (FrameworkVersion version : versions) {
|
||||
List<DownloadableFileDescription> downloads = new ArrayList<DownloadableFileDescription>();
|
||||
List<DownloadableLibraryFileDescription> downloads = new ArrayList<DownloadableLibraryFileDescription>();
|
||||
for (LibraryInfo info : version.getLibraries()) {
|
||||
final LibraryDownloadInfo downloadingInfo = info.getDownloadingInfo();
|
||||
if (downloadingInfo != null) {
|
||||
final DownloadableFileDescription
|
||||
element = new DownloadableFileDescriptionImpl(downloadingInfo.getDownloadUrl(), downloadingInfo.getFileNamePrefix(), downloadingInfo.getFileNameSuffix());
|
||||
downloads.add(element);
|
||||
downloads.add(new DownloadableLibraryFileDescriptionImpl(downloadingInfo.getDownloadUrl(), downloadingInfo.getFileNamePrefix(),
|
||||
downloadingInfo.getFileNameSuffix(), null, null, false));
|
||||
}
|
||||
}
|
||||
libraryVersions.add(new FrameworkLibraryVersionImpl(version.getVersionName(), downloads, version.getLibraryName()));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.intellij.util.descriptors.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener;
|
||||
@@ -43,7 +42,6 @@ public class ConfigFileImpl implements ConfigFile {
|
||||
}
|
||||
});
|
||||
onChange();
|
||||
Disposer.register(container, this);
|
||||
myProject = myContainer.getProject();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.completion;
|
||||
|
||||
import com.intellij.psi.PsiKeyword;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiParameterList;
|
||||
import com.intellij.psi.filters.AndFilter;
|
||||
import com.intellij.psi.filters.ClassFilter;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.filters.TextFilter;
|
||||
import com.intellij.psi.filters.classes.InterfaceFilter;
|
||||
import com.intellij.psi.filters.position.LeftNeighbour;
|
||||
import com.intellij.psi.filters.position.ParentElementFilter;
|
||||
|
||||
public class Java18CompletionData extends Java15CompletionData {
|
||||
@Override
|
||||
protected void initVariantsInMethodScope() {
|
||||
super.initVariantsInMethodScope();
|
||||
|
||||
{
|
||||
// in extension method
|
||||
ElementFilter position = new AndFilter(
|
||||
new LeftNeighbour(new AndFilter(
|
||||
new TextFilter(")"),
|
||||
new ParentElementFilter(new ClassFilter(PsiParameterList.class)))),
|
||||
new ParentElementFilter(new InterfaceFilter(), 3));
|
||||
CompletionVariant variant = new CompletionVariant(PsiMethod.class, position);
|
||||
variant.addCompletion(PsiKeyword.DEFAULT);
|
||||
registerVariant(variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-4
@@ -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.
|
||||
@@ -36,6 +36,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PatternCondition;
|
||||
import com.intellij.patterns.PsiNameValuePairPattern;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.*;
|
||||
import com.intellij.psi.filters.classes.AssignableFromContextFilter;
|
||||
@@ -66,8 +67,22 @@ import static com.intellij.patterns.PsiJavaPatterns.*;
|
||||
public class JavaCompletionContributor extends CompletionContributor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.JavaCompletionContributor");
|
||||
|
||||
private static final Java15CompletionData ourJava15CompletionData = new Java15CompletionData();
|
||||
private static final JavaCompletionData ourJavaCompletionData = new JavaCompletionData();
|
||||
private static final Map<LanguageLevel, JavaCompletionData> ourCompletionData;
|
||||
|
||||
static {
|
||||
ourCompletionData = new LinkedHashMap<LanguageLevel, JavaCompletionData>();
|
||||
ourCompletionData.put(LanguageLevel.JDK_1_8, new Java18CompletionData());
|
||||
ourCompletionData.put(LanguageLevel.JDK_1_3, new Java15CompletionData());
|
||||
ourCompletionData.put(LanguageLevel.JDK_1_3, new JavaCompletionData());
|
||||
}
|
||||
|
||||
private static JavaCompletionData getCompletionData(LanguageLevel level) {
|
||||
final Set<Map.Entry<LanguageLevel, JavaCompletionData>> entries = ourCompletionData.entrySet();
|
||||
for (Map.Entry<LanguageLevel, JavaCompletionData> entry : entries) {
|
||||
if (entry.getKey().isAtLeast(level)) return entry.getValue();
|
||||
}
|
||||
return ourCompletionData.get(LanguageLevel.JDK_1_3);
|
||||
}
|
||||
|
||||
private static final PsiNameValuePairPattern NAME_VALUE_PAIR =
|
||||
psiNameValuePair().withSuperParent(2, psiElement(PsiAnnotation.class));
|
||||
@@ -338,7 +353,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
PsiElement position = parameters.getPosition();
|
||||
final Set<LookupElement> lookupSet = new LinkedHashSet<LookupElement>();
|
||||
final Set<CompletionVariant> keywordVariants = new HashSet<CompletionVariant>();
|
||||
final JavaCompletionData completionData = PsiUtil.isLanguageLevel5OrHigher(position) ? ourJava15CompletionData : ourJavaCompletionData;
|
||||
final JavaCompletionData completionData = getCompletionData(PsiUtil.getLanguageLevel(position));
|
||||
completionData.addKeywordVariants(keywordVariants, position, parameters.getOriginalFile());
|
||||
completionData.completeKeywordsBySet(lookupSet, keywordVariants, position, result.getPrefixMatcher(), parameters.getOriginalFile());
|
||||
completionData.fillCompletions(parameters, result);
|
||||
|
||||
@@ -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.
|
||||
@@ -311,7 +311,7 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
}
|
||||
}
|
||||
|
||||
private void initVariantsInMethodScope() {
|
||||
protected void initVariantsInMethodScope() {
|
||||
// Completion for classes in method throws section
|
||||
// position
|
||||
{
|
||||
@@ -363,7 +363,7 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
registerVariant(variant);
|
||||
}
|
||||
|
||||
// Catch/Finnaly completion
|
||||
// Catch/Finally completion
|
||||
{
|
||||
final ElementFilter position = new LeftNeighbour(new AndFilter(
|
||||
new TextFilter("}"),
|
||||
|
||||
+11
-10
@@ -678,6 +678,7 @@ public class HighlightClassUtil {
|
||||
* @param extendRef points to the class in the extends list
|
||||
* @param resolved extendRef resolved
|
||||
*/
|
||||
@Nullable
|
||||
public static HighlightInfo checkClassExtendsForeignInnerClass(final PsiJavaCodeReferenceElement extendRef, final PsiElement resolved) {
|
||||
PsiElement parent = extendRef.getParent();
|
||||
if (!(parent instanceof PsiReferenceList)) {
|
||||
@@ -723,11 +724,10 @@ public class HighlightClassUtil {
|
||||
// must be inner class
|
||||
if (!PsiUtil.isInnerClass(base)) return;
|
||||
|
||||
if (resolve == resolved) {
|
||||
if (!hasEnclosingInstanceInScope(baseClass, extendRef, true) && !qualifiedNewCalledInConstructors(aClass, baseClass)) {
|
||||
String description = JavaErrorMessages.message("no.enclosing.instance.in.scope", HighlightUtil.formatClass(baseClass));
|
||||
infos[0] = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, extendRef, description);
|
||||
}
|
||||
if (resolve == resolved && baseClass != null &&
|
||||
!hasEnclosingInstanceInScope(baseClass, extendRef, true) && !qualifiedNewCalledInConstructors(aClass, baseClass)) {
|
||||
String description = JavaErrorMessages.message("no.enclosing.instance.in.scope", HighlightUtil.formatClass(baseClass));
|
||||
infos[0] = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, extendRef, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,6 +796,7 @@ public class HighlightClassUtil {
|
||||
return checkCreateInnerClassFromStaticContext(expression, qualifier, aClass);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkCreateInnerClassFromStaticContext(PsiElement element, @Nullable PsiExpression qualifier, PsiClass aClass) {
|
||||
if (!PsiUtil.isInnerClass(aClass)) return null;
|
||||
PsiClass outerClass = aClass.getContainingClass();
|
||||
@@ -803,15 +804,14 @@ public class HighlightClassUtil {
|
||||
|
||||
PsiElement placeToSearchEnclosingFrom;
|
||||
if (qualifier != null) {
|
||||
PsiType qtype = qualifier.getType();
|
||||
placeToSearchEnclosingFrom = PsiUtil.resolveClassInType(qtype);
|
||||
PsiType qType = qualifier.getType();
|
||||
placeToSearchEnclosingFrom = PsiUtil.resolveClassInType(qType);
|
||||
}
|
||||
else {
|
||||
placeToSearchEnclosingFrom = element;
|
||||
}
|
||||
|
||||
if (outerClass instanceof JspClass
|
||||
|| hasEnclosingInstanceInScope(outerClass, placeToSearchEnclosingFrom, true)) return null;
|
||||
if (outerClass instanceof JspClass || hasEnclosingInstanceInScope(outerClass, placeToSearchEnclosingFrom, true)) return null;
|
||||
return reportIllegalEnclosingUsage(placeToSearchEnclosingFrom, aClass, outerClass, element);
|
||||
}
|
||||
|
||||
@@ -837,7 +837,8 @@ public class HighlightClassUtil {
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo reportIllegalEnclosingUsage(PsiElement place,
|
||||
PsiClass aClass, PsiClass outerClass,
|
||||
@Nullable PsiClass aClass,
|
||||
PsiClass outerClass,
|
||||
PsiElement elementToHighlight) {
|
||||
if (outerClass != null && !PsiTreeUtil.isContextAncestor(outerClass, place, false)) {
|
||||
String description = JavaErrorMessages.message("is.not.an.enclosing.class", HighlightUtil.formatClass(outerClass));
|
||||
|
||||
+171
-121
@@ -67,7 +67,7 @@ import static com.intellij.codeInsight.daemon.JavaHighlightingFilter.suppressed;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
* Date: Jul 30, 2002
|
||||
* @since Jul 30, 2002
|
||||
*/
|
||||
public class HighlightUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil");
|
||||
@@ -534,14 +534,14 @@ public class HighlightUtil {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorResult = checkAssignability(returnType, valueType, returnValue, statement);
|
||||
if (errorResult != null && valueType != null) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix);
|
||||
if (returnType instanceof PsiArrayType && TypeConversionUtil.isAssignable(((PsiArrayType)returnType).getComponentType(), valueType)) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new SurroundWithArrayFix(null){
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new SurroundWithArrayFix(null) {
|
||||
@Override
|
||||
protected PsiExpression getExpression(final PsiElement element) {
|
||||
return returnValue.isValid() ? returnValue : null;
|
||||
@@ -580,7 +580,10 @@ public class HighlightUtil {
|
||||
|
||||
private static String formatTypes(Collection<PsiClassType> unhandled) {
|
||||
return StringUtil.join(unhandled, new Function<PsiClassType, String>() {
|
||||
@Override public String fun(PsiClassType type) { return formatType(type); }
|
||||
@Override
|
||||
public String fun(PsiClassType type) {
|
||||
return formatType(type);
|
||||
}
|
||||
}, ", ");
|
||||
}
|
||||
|
||||
@@ -825,7 +828,8 @@ public class HighlightUtil {
|
||||
}
|
||||
else {
|
||||
if (PsiModifier.PUBLIC.equals(modifier)) {
|
||||
isAllowed = modifierOwnerParent instanceof PsiJavaFile || (modifierOwnerParent instanceof PsiClass && (modifierOwnerParent instanceof JspClass || ((PsiClass)modifierOwnerParent).getQualifiedName() != null));
|
||||
isAllowed = modifierOwnerParent instanceof PsiJavaFile ||
|
||||
(modifierOwnerParent instanceof PsiClass && (modifierOwnerParent instanceof JspClass || ((PsiClass)modifierOwnerParent).getQualifiedName() != null));
|
||||
}
|
||||
else if (PsiModifier.STATIC.equals(modifier) || PsiModifier.PRIVATE.equals(modifier) || PsiModifier.PROTECTED.equals(modifier) ||
|
||||
PsiModifier.PACKAGE_LOCAL.equals(modifier)) {
|
||||
@@ -879,41 +883,30 @@ public class HighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkLiteralExpressionParsingError(final PsiLiteralExpression expression) {
|
||||
final String error = getLiteralExpressionParsingError(expression);
|
||||
if (error != null) {
|
||||
final HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, error);
|
||||
QuickFixAction.registerQuickFixActions(info, getLiteralExpressionQuickFixes(expression));
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Key<Boolean> TOO_BIG_CHAR_LITERAL_KEY = Key.create("too.big.char.literal");
|
||||
|
||||
public static String getLiteralExpressionParsingError(final PsiLiteralExpression expression) {
|
||||
public static HighlightInfo checkLiteralExpressionParsingError(final PsiLiteralExpression expression) {
|
||||
final Object value = expression.getValue();
|
||||
final PsiElement literal = expression.getFirstChild();
|
||||
assert literal instanceof PsiJavaToken : literal;
|
||||
final IElementType type = ((PsiJavaToken)literal).getTokenType();
|
||||
String text = PsiLiteralExpressionImpl.NUMERIC_LITERALS.contains(type) ? literal.getText().toLowerCase() : literal.getText();
|
||||
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expression);
|
||||
|
||||
if (PsiLiteralExpressionImpl.REAL_LITERALS.contains(type)) {
|
||||
if (text.startsWith(PsiLiteralExpressionImpl.HEX_PREFIX) && !languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) {
|
||||
return JavaErrorMessages.message("hex.FP.literals.not.supported");
|
||||
if (text.startsWith(PsiLiteralExpressionImpl.HEX_PREFIX)) {
|
||||
final HighlightInfo info = checkFeature(expression, Feature.HEX_FP_LITERALS);
|
||||
if (info != null) return info;
|
||||
}
|
||||
}
|
||||
if (PsiLiteralExpressionImpl.INTEGER_LITERALS.contains(type)) {
|
||||
if (text.startsWith(PsiLiteralExpressionImpl.BIN_PREFIX) && !languageLevel.isAtLeast(LanguageLevel.JDK_1_7)) {
|
||||
return JavaErrorMessages.message("binary.literals.not.supported");
|
||||
if (text.startsWith(PsiLiteralExpressionImpl.BIN_PREFIX)) {
|
||||
final HighlightInfo info = checkFeature(expression, Feature.BIN_LITERALS);
|
||||
if (info != null) return info;
|
||||
}
|
||||
}
|
||||
if (PsiLiteralExpressionImpl.NUMERIC_LITERALS.contains(type)) {
|
||||
if (text.contains("_") && !languageLevel.isAtLeast(LanguageLevel.JDK_1_7)) {
|
||||
return JavaErrorMessages.message("underscores.in.literals.not.supported");
|
||||
if (text.contains("_")) {
|
||||
final HighlightInfo info = checkFeature(expression, Feature.UNDERSCORES);
|
||||
if (info != null) return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,13 +917,16 @@ public class HighlightUtil {
|
||||
parent instanceof PsiPrefixExpression &&
|
||||
((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) {
|
||||
if (text.equals(PsiLiteralExpressionImpl.HEX_PREFIX)) {
|
||||
return JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
final String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (text.equals(PsiLiteralExpressionImpl.BIN_PREFIX)) {
|
||||
return JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
final String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (value == null || text.equals(PsiLiteralExpressionImpl._2_IN_31)) {
|
||||
return JavaErrorMessages.message("integer.number.too.large");
|
||||
final String message = JavaErrorMessages.message("integer.number.too.large");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -941,19 +937,23 @@ public class HighlightUtil {
|
||||
parent instanceof PsiPrefixExpression &&
|
||||
((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) {
|
||||
if (mText.equals(PsiLiteralExpressionImpl.HEX_PREFIX)) {
|
||||
return JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
final String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (mText.equals(PsiLiteralExpressionImpl.BIN_PREFIX)) {
|
||||
return JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
final String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (value == null || mText.equals(PsiLiteralExpressionImpl._2_IN_63)) {
|
||||
return JavaErrorMessages.message("long.number.too.large");
|
||||
final String message = JavaErrorMessages.message("long.number.too.large");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == JavaTokenType.FLOAT_LITERAL || type == JavaTokenType.DOUBLE_LITERAL) {
|
||||
if (value == null) {
|
||||
return JavaErrorMessages.message("malformed.floating.point.literal");
|
||||
final String message = JavaErrorMessages.message("malformed.floating.point.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
else if (type == JavaTokenType.TRUE_KEYWORD || type == JavaTokenType.FALSE_KEYWORD || type == JavaTokenType.NULL_KEYWORD) {
|
||||
@@ -962,28 +962,41 @@ public class HighlightUtil {
|
||||
else if (type == JavaTokenType.CHARACTER_LITERAL) {
|
||||
// todo[r.sh] clean this mess up
|
||||
if (value != null) {
|
||||
if (!StringUtil.endsWithChar(text, '\'')) return JavaErrorMessages.message("unclosed.char.literal");
|
||||
if (!StringUtil.endsWithChar(text, '\'')) {
|
||||
final String message = JavaErrorMessages.message("unclosed.char.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!StringUtil.startsWithChar(text, '\'')) return null;
|
||||
if (StringUtil.endsWithChar(text, '\'')) {
|
||||
if (text.length() == 1) return JavaErrorMessages.message("illegal.line.end.in.character.literal");
|
||||
if (text.length() == 1) {
|
||||
final String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
text = text.substring(1, text.length() - 1);
|
||||
}
|
||||
else {
|
||||
return JavaErrorMessages.message("illegal.line.end.in.character.literal");
|
||||
final String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
final StringBuilder chars = StringBuilderSpinAllocator.alloc();
|
||||
final boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null);
|
||||
if (!success) return JavaErrorMessages.message("illegal.escape.character.in.character.literal");
|
||||
if (!success) {
|
||||
final String message = JavaErrorMessages.message("illegal.escape.character.in.character.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
final int length = chars.length();
|
||||
StringBuilderSpinAllocator.dispose(chars);
|
||||
if (length > 1) {
|
||||
literal.putUserData(TOO_BIG_CHAR_LITERAL_KEY, Boolean.TRUE);
|
||||
return JavaErrorMessages.message("too.many.characters.in.character.literal");
|
||||
final String message = JavaErrorMessages.message("too.many.characters.in.character.literal");
|
||||
final HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
QuickFixAction.registerQuickFixAction(info, new ConvertToStringLiteralAction());
|
||||
return info;
|
||||
}
|
||||
else if (length == 0) {
|
||||
return JavaErrorMessages.message("empty.character.literal");
|
||||
final String message = JavaErrorMessages.message("empty.character.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,27 +1010,46 @@ public class HighlightUtil {
|
||||
|
||||
if (!StringUtil.startsWithChar(text, '\"')) return null;
|
||||
if (StringUtil.endsWithChar(text, '\"')) {
|
||||
if (text.length() == 1) return JavaErrorMessages.message("illegal.line.end.in.string.literal");
|
||||
if (text.length() == 1) {
|
||||
final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
text = text.substring(1, text.length() - 1);
|
||||
}
|
||||
else {
|
||||
return JavaErrorMessages.message("illegal.line.end.in.string.literal");
|
||||
final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
StringBuilder chars = new StringBuilder();
|
||||
boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null);
|
||||
if (!success) return JavaErrorMessages.message("illegal.escape.character.in.string.literal");
|
||||
if (!success) {
|
||||
final String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value instanceof Float) {
|
||||
final Float number = (Float)value;
|
||||
if (number.isInfinite()) return JavaErrorMessages.message("floating.point.number.too.large");
|
||||
if (number.floatValue() == 0 && !isFPZero(text)) return JavaErrorMessages.message("floating.point.number.too.small");
|
||||
if (number.isInfinite()) {
|
||||
final String message = JavaErrorMessages.message("floating.point.number.too.large");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (number.floatValue() == 0 && !isFPZero(text)) {
|
||||
final String message = JavaErrorMessages.message("floating.point.number.too.small");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
else if (value instanceof Double) {
|
||||
final Double number = (Double)value;
|
||||
if (number.isInfinite()) return JavaErrorMessages.message("floating.point.number.too.large");
|
||||
if (number.doubleValue() == 0 && !isFPZero(text)) return JavaErrorMessages.message("floating.point.number.too.small");
|
||||
if (number.isInfinite()) {
|
||||
final String message = JavaErrorMessages.message("floating.point.number.too.large");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
if (number.doubleValue() == 0 && !isFPZero(text)) {
|
||||
final String message = JavaErrorMessages.message("floating.point.number.too.small");
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -1033,33 +1065,6 @@ public class HighlightUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Collection<? extends IntentionAction> getLiteralExpressionQuickFixes(final PsiLiteralExpression expression) {
|
||||
final PsiElement literal = expression.getFirstChild();
|
||||
assert literal instanceof PsiJavaToken : literal;
|
||||
final String text = literal.getText().toLowerCase();
|
||||
final IElementType type = ((PsiJavaToken)literal).getTokenType();
|
||||
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expression);
|
||||
|
||||
if (PsiLiteralExpressionImpl.REAL_LITERALS.contains(type)) {
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5) && text.startsWith(PsiLiteralExpressionImpl.HEX_PREFIX)) {
|
||||
return Collections.singletonList(new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_5));
|
||||
}
|
||||
}
|
||||
if (PsiLiteralExpressionImpl.NUMERIC_LITERALS.contains(type)) {
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_7) && (text.startsWith(PsiLiteralExpressionImpl.BIN_PREFIX) || text.contains("_"))) {
|
||||
return Collections.singletonList(new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_7));
|
||||
}
|
||||
}
|
||||
if (type == JavaTokenType.CHARACTER_LITERAL) {
|
||||
if (Boolean.TRUE.equals(literal.getUserData(TOO_BIG_CHAR_LITERAL_KEY))) {
|
||||
return Collections.singletonList(new ConvertToStringLiteralAction());
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkMustBeBoolean(@NotNull PsiExpression expr, PsiType type) {
|
||||
PsiElement parent = expr.getParent();
|
||||
@@ -1071,7 +1076,7 @@ public class HighlightUtil {
|
||||
if (!TypeConversionUtil.isBooleanType(type)) {
|
||||
final HighlightInfo info = createIncompatibleTypeHighlightInfo(PsiType.BOOLEAN, type, expr.getTextRange());
|
||||
if (expr instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression) expr;
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)expr;
|
||||
final PsiMethod method = methodCall.resolveMethod();
|
||||
if (method != null && PsiType.VOID.equals(method.getReturnType())) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.BOOLEAN, true);
|
||||
@@ -1140,8 +1145,7 @@ public class HighlightUtil {
|
||||
final List<PsiTypeElement> typeElements = PsiUtil.getParameterTypeElements(parameter);
|
||||
final Collection<HighlightInfo> highlights = Lists.newArrayListWithCapacity(typeElements.size());
|
||||
|
||||
for (int i = 0, size = typeElements.size(); i < size; i++) {
|
||||
final PsiTypeElement typeElement = typeElements.get(i);
|
||||
for (final PsiTypeElement typeElement : typeElements) {
|
||||
final PsiType catchType = typeElement.getType();
|
||||
if (catchType instanceof PsiClassType && ExceptionUtil.isUncheckedExceptionOrSuperclass((PsiClassType)catchType)) continue;
|
||||
|
||||
@@ -1188,7 +1192,10 @@ public class HighlightUtil {
|
||||
|
||||
// collect exceptions which are caught by this type
|
||||
Collection<PsiClassType> caught = ContainerUtil.findAll(thrownTypes, new Condition<PsiClassType>() {
|
||||
@Override public boolean value(PsiClassType type) { return catchType.isAssignableFrom(type); }
|
||||
@Override
|
||||
public boolean value(PsiClassType type) {
|
||||
return catchType.isAssignableFrom(type);
|
||||
}
|
||||
});
|
||||
if (caught.isEmpty()) continue;
|
||||
final Collection<PsiClassType> caughtCopy = Sets.newHashSet(caught);
|
||||
@@ -1247,7 +1254,8 @@ public class HighlightUtil {
|
||||
if (PsiType.LONG.equals(type) || PsiType.FLOAT.equals(type) || PsiType.DOUBLE.equals(type)) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new AddTypeCastFix(PsiType.INT, expression));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final PsiClass member = PsiUtil.resolveClassInClassTypeOnly(type);
|
||||
if (member != null && !PsiUtil.isAccessible(member, expression, null)) {
|
||||
String message = PsiFormatUtil.formatClass(member, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME) + " is inaccessible here";
|
||||
@@ -1285,8 +1293,8 @@ public class HighlightUtil {
|
||||
if (!TypeConversionUtil.isBinaryOperatorApplicable(operationSign, lType, rType, false)) {
|
||||
PsiJavaToken token = expression.getTokenBeforeOperand(operand);
|
||||
String message = JavaErrorMessages.message("binary.operator.not.applicable", token.getText(),
|
||||
formatType(lType),
|
||||
formatType(rType));
|
||||
formatType(lType),
|
||||
formatType(rType));
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
lType = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, operationSign, true);
|
||||
@@ -1314,29 +1322,56 @@ public class HighlightUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkThisOrSuperExpressionInIllegalContext(PsiExpression expr, @Nullable PsiJavaCodeReferenceElement qualifier) {
|
||||
if (expr instanceof PsiSuperExpression && !(expr.getParent() instanceof PsiReferenceExpression)) {
|
||||
// like in 'Object o = super;'
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expr.getTextRange().getEndOffset(),
|
||||
expr.getTextRange().getEndOffset() + 1,
|
||||
JavaErrorMessages.message("dot.expected.after.super.or.this"));
|
||||
public static HighlightInfo checkThisOrSuperExpressionInIllegalContext(PsiExpression expr,
|
||||
@Nullable PsiJavaCodeReferenceElement qualifier) {
|
||||
if (expr instanceof PsiSuperExpression) {
|
||||
final PsiElement parent = expr.getParent();
|
||||
if (!(parent instanceof PsiReferenceExpression)) {
|
||||
// like in 'Object o = super;'
|
||||
final int o = expr.getTextRange().getEndOffset();
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, o, o + 1, JavaErrorMessages.message("dot.expected.after.super.or.this"));
|
||||
}
|
||||
|
||||
if (PsiUtil.isLanguageLevel8OrHigher(expr)) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(expr, PsiMethod.class);
|
||||
if (PsiUtil.isExtensionMethod(method) && qualifier == null) {
|
||||
//todo[r.sh] "Add qualifier" quick fix
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parent, JavaErrorMessages.message("unqualified.super.disallowed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiElement resolved = null;
|
||||
PsiClass aClass = qualifier == null ? PsiTreeUtil.getParentOfType(expr, PsiClass.class) : (resolved = qualifier.resolve()) instanceof PsiClass ? (PsiClass)resolved : null;
|
||||
if (resolved != null && !(resolved instanceof PsiClass)) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("class.expected"));
|
||||
|
||||
final PsiClass aClass;
|
||||
if (qualifier != null) {
|
||||
final PsiElement resolved = qualifier.resolve();
|
||||
if (resolved != null && !(resolved instanceof PsiClass)) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("class.expected"));
|
||||
}
|
||||
aClass = (PsiClass)resolved;
|
||||
}
|
||||
else {
|
||||
aClass = PsiTreeUtil.getParentOfType(expr, PsiClass.class);
|
||||
}
|
||||
if (aClass == null) return null;
|
||||
if (qualifier != null && aClass.isInterface()) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, JavaErrorMessages.message("no.interface.expected"));
|
||||
}
|
||||
if (!HighlightClassUtil.hasEnclosingInstanceInScope(aClass, expr, false)) {
|
||||
|
||||
if (!HighlightClassUtil.hasEnclosingInstanceInScope(aClass, expr, false) &&
|
||||
!resolvesToImmediateSuperInterface(expr, qualifier, aClass)) {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean resolvesToImmediateSuperInterface(PsiExpression expr,
|
||||
@Nullable PsiJavaCodeReferenceElement qualifier,
|
||||
PsiClass aClass) {
|
||||
if (!(expr instanceof PsiSuperExpression) || qualifier == null || !PsiUtil.isLanguageLevel8OrHigher(expr)) return false;
|
||||
final PsiType superType = expr.getType();
|
||||
if (!(superType instanceof PsiClassType)) return false;
|
||||
final PsiClass superClass = ((PsiClassType)superType).resolve();
|
||||
return superClass != null && aClass.equals(superClass);
|
||||
}
|
||||
|
||||
static String buildProblemWithStaticDescription(PsiElement refElement) {
|
||||
String type = LanguageFindUsages.INSTANCE.forLanguage(JavaLanguage.INSTANCE).getType(refElement);
|
||||
String name = HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY);
|
||||
@@ -1406,13 +1441,19 @@ public class HighlightUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkValidArrayAccessExpression(@Nullable PsiExpression arrayExpression, PsiExpression indexExpression, PsiType type) {
|
||||
PsiType arrayExpressionType = arrayExpression == null ? null : arrayExpression.getType();
|
||||
static HighlightInfo checkValidArrayAccessExpression(@NotNull PsiArrayAccessExpression arrayAccessExpression) {
|
||||
final PsiExpression arrayExpression = arrayAccessExpression.getArrayExpression();
|
||||
final PsiType arrayExpressionType = arrayExpression.getType();
|
||||
|
||||
if (arrayExpressionType != null && !(arrayExpressionType instanceof PsiArrayType)) {
|
||||
String description = JavaErrorMessages.message("array.type.expected", formatType(arrayExpressionType));
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, arrayExpression, description);
|
||||
final String description = JavaErrorMessages.message("array.type.expected", formatType(arrayExpressionType));
|
||||
final HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, arrayExpression, description);
|
||||
QuickFixAction.registerQuickFixAction(info, new ReplaceWithListAccessFix(arrayAccessExpression));
|
||||
return info;
|
||||
}
|
||||
return checkAssignability(PsiType.INT, indexExpression.getType(), indexExpression, indexExpression);
|
||||
|
||||
final PsiExpression indexExpression = arrayAccessExpression.getIndexExpression();
|
||||
return indexExpression != null ? checkAssignability(PsiType.INT, indexExpression.getType(), indexExpression, indexExpression) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1440,8 +1481,8 @@ public class HighlightUtil {
|
||||
if (!(initializer instanceof PsiArrayInitializerExpression)) return null;
|
||||
if (!(type instanceof PsiArrayType)) return null;
|
||||
|
||||
final PsiType componentType = ((PsiArrayType) type).getComponentType();
|
||||
final PsiArrayInitializerExpression arrayInitializer = (PsiArrayInitializerExpression) initializer;
|
||||
final PsiType componentType = ((PsiArrayType)type).getComponentType();
|
||||
final PsiArrayInitializerExpression arrayInitializer = (PsiArrayInitializerExpression)initializer;
|
||||
|
||||
boolean arrayTypeFixChecked = false;
|
||||
VariableArrayTypeFix fix = null;
|
||||
@@ -1535,7 +1576,8 @@ public class HighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, JavaErrorMessages.message("array.initializer.not.allowed"));
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression,
|
||||
JavaErrorMessages.message("array.initializer.not.allowed"));
|
||||
QuickFixAction.registerQuickFixAction(info, new AddNewArrayExpressionFix(expression));
|
||||
return info;
|
||||
}
|
||||
@@ -1617,7 +1659,7 @@ public class HighlightUtil {
|
||||
String description = JavaErrorMessages.message("switch.colon.expected.after.case.label");
|
||||
CharSequence chars = statement.getContainingFile().getViewProvider().getContents();
|
||||
boolean isAfterEndOfLine = end >= chars.length() || chars.charAt(start) == '\n' || chars.charAt(start) == '\r';
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, null,start, end, description, description,isAfterEndOfLine, null);
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, null, start, end, description, description, isAfterEndOfLine, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1709,10 +1751,10 @@ public class HighlightUtil {
|
||||
if (((PsiMethod)typeOwner).getReturnTypeElement() == parent) return null;
|
||||
}
|
||||
else if (// like in Class c = void.class;
|
||||
typeOwner instanceof PsiClassObjectAccessExpression &&
|
||||
TypeConversionUtil.isVoidType(((PsiClassObjectAccessExpression)typeOwner).getOperand().getType()) ||
|
||||
// do not highlight incomplete declarations
|
||||
typeOwner != null && PsiUtilCore.hasErrorElementChild(typeOwner)) {
|
||||
typeOwner instanceof PsiClassObjectAccessExpression &&
|
||||
TypeConversionUtil.isVoidType(((PsiClassObjectAccessExpression)typeOwner).getOperand().getType()) ||
|
||||
// do not highlight incomplete declarations
|
||||
typeOwner != null && PsiUtilCore.hasErrorElementChild(typeOwner)) {
|
||||
return null;
|
||||
}
|
||||
else if (typeOwner instanceof JavaCodeFragment) {
|
||||
@@ -1733,7 +1775,9 @@ public class HighlightUtil {
|
||||
// redirected ctr
|
||||
if (PsiKeyword.THIS.equals(((PsiJavaCodeReferenceElement)expression).getReferenceName())
|
||||
&& resolved instanceof PsiMethod
|
||||
&& ((PsiMethod)resolved).isConstructor()) return null;
|
||||
&& ((PsiMethod)resolved).isConstructor()) {
|
||||
return null;
|
||||
}
|
||||
PsiElement qualifier = ((PsiJavaCodeReferenceElement)expression).getQualifier();
|
||||
type = qualifier instanceof PsiExpression ? ((PsiExpression)qualifier).getType() : null;
|
||||
referencedClass = PsiUtil.resolveClassInType(type);
|
||||
@@ -1785,7 +1829,7 @@ public class HighlightUtil {
|
||||
resolvedName = qualifier.getText();
|
||||
}
|
||||
}
|
||||
else if (PsiKeyword.THIS.equals(name)) {
|
||||
else if (PsiKeyword.THIS.equals(name)) {
|
||||
resolvedName = PsiKeyword.THIS;
|
||||
}
|
||||
else {
|
||||
@@ -1891,11 +1935,11 @@ public class HighlightUtil {
|
||||
PsiMethod[] constructors = aClass.getConstructors();
|
||||
if (constructors.length == 0) {
|
||||
TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
|
||||
return createMemberReferencedError(aClass.getName()+".this", range);
|
||||
return createMemberReferencedError(aClass.getName() + ".this", range);
|
||||
}
|
||||
for (PsiMethod constructor : constructors) {
|
||||
if (!isSuperCalledInConstructor(constructor)) {
|
||||
return createMemberReferencedError(aClass.getName()+".this", HighlightNamesUtil.getMethodDeclarationTextRange(constructor));
|
||||
return createMemberReferencedError(aClass.getName() + ".this", HighlightNamesUtil.getMethodDeclarationTextRange(constructor));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -1908,12 +1952,12 @@ public class HighlightUtil {
|
||||
if (statements.length == 0) return false;
|
||||
final PsiStatement statement = statements[0];
|
||||
final PsiElement element = new PsiMatcherImpl(statement)
|
||||
.dot(PsiMatchers.hasClass(PsiExpressionStatement.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiMethodCallExpression.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiReferenceExpression.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiKeyword.class))
|
||||
.dot(PsiMatchers.hasText(PsiKeyword.SUPER))
|
||||
.getElement();
|
||||
.dot(PsiMatchers.hasClass(PsiExpressionStatement.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiMethodCallExpression.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiReferenceExpression.class))
|
||||
.firstChild(PsiMatchers.hasClass(PsiKeyword.class))
|
||||
.dot(PsiMatchers.hasText(PsiKeyword.SUPER))
|
||||
.getElement();
|
||||
return element != null;
|
||||
}
|
||||
|
||||
@@ -1923,10 +1967,12 @@ public class HighlightUtil {
|
||||
PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)element).getMethodExpression();
|
||||
return methodExpression.getReferenceName();
|
||||
}
|
||||
|
||||
public static boolean isSuperOrThisMethodCall(PsiElement element) {
|
||||
String name = getMethodExpressionName(element);
|
||||
return PsiKeyword.SUPER.equals(name) || PsiKeyword.THIS.equals(name);
|
||||
}
|
||||
|
||||
public static boolean isSuperMethodCall(PsiElement element) {
|
||||
String name = getMethodExpressionName(element);
|
||||
return PsiKeyword.SUPER.equals(name);
|
||||
@@ -2362,7 +2408,8 @@ public class HighlightUtil {
|
||||
}
|
||||
if ((resolved instanceof PsiLocalVariable || resolved instanceof PsiParameter) && !(resolved instanceof ImplicitVariable)) {
|
||||
highlightInfo = HighlightControlFlowUtil.checkVariableMustBeFinal((PsiVariable)resolved, ref);
|
||||
} else if (resolved instanceof PsiClass) {
|
||||
}
|
||||
else if (resolved instanceof PsiClass) {
|
||||
if (Comparing.strEqual(((PsiClass)resolved).getQualifiedName(), ((PsiClass)resolved).getName())) {
|
||||
final PsiElement parent = ref.getParent();
|
||||
if (parent instanceof PsiImportStaticReferenceElement || parent instanceof PsiImportStatementBase) {
|
||||
@@ -2391,8 +2438,8 @@ public class HighlightUtil {
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkElementInReferenceList(PsiJavaCodeReferenceElement ref,
|
||||
PsiReferenceList referenceList,
|
||||
JavaResolveResult resolveResult) {
|
||||
PsiReferenceList referenceList,
|
||||
JavaResolveResult resolveResult) {
|
||||
PsiElement resolved = resolveResult.getElement();
|
||||
HighlightInfo highlightInfo = null;
|
||||
PsiElement refGrandParent = referenceList.getParent();
|
||||
@@ -2478,9 +2525,12 @@ public class HighlightUtil {
|
||||
STATIC_IMPORTS(LanguageLevel.JDK_1_5, "feature.static.imports"),
|
||||
FOR_EACH(LanguageLevel.JDK_1_5, "feature.for.each"),
|
||||
VARARGS(LanguageLevel.JDK_1_5, "feature.varargs"),
|
||||
HEX_FP_LITERALS(LanguageLevel.JDK_1_5, "feature.hex.fp.literals"),
|
||||
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"),
|
||||
BIN_LITERALS(LanguageLevel.JDK_1_7, "feature.binary.literals"),
|
||||
UNDERSCORES(LanguageLevel.JDK_1_7, "feature.underscores.in.literals"),
|
||||
EXTENSION_METHODS(LanguageLevel.JDK_1_8, "feature.extension.methods");
|
||||
|
||||
private final LanguageLevel level;
|
||||
|
||||
+8
-10
@@ -79,7 +79,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public HighlightVisitorImpl(@NotNull PsiResolveHelper resolveHelper) {
|
||||
myResolveHelper = resolveHelper;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public int order() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suitableForFile(@NotNull PsiFile file) {
|
||||
@@ -324,22 +324,20 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
@Override public void visitExpression(PsiExpression expression) {
|
||||
ProgressManager.checkCanceled(); // visitLiteralExpression is invoked very often in array initializers
|
||||
|
||||
|
||||
super.visitExpression(expression);
|
||||
PsiType type = expression.getType();
|
||||
if (myHolder.add(HighlightUtil.checkMustBeBoolean(expression, type))) return;
|
||||
PsiExpression indexExpression;
|
||||
|
||||
if (expression instanceof PsiArrayAccessExpression
|
||||
&& (indexExpression = ((PsiArrayAccessExpression)expression).getIndexExpression()) != null) {
|
||||
PsiExpression arrayExpression = ((PsiArrayAccessExpression)expression).getArrayExpression();
|
||||
myHolder.add(HighlightUtil.checkValidArrayAccessExpression(arrayExpression, indexExpression, indexExpression.getType()));
|
||||
if(expression instanceof PsiArrayAccessExpression) {
|
||||
myHolder.add(HighlightUtil.checkValidArrayAccessExpression((PsiArrayAccessExpression)expression));
|
||||
}
|
||||
|
||||
if (expression.getParent() instanceof PsiNewExpression
|
||||
&& ((PsiNewExpression)expression.getParent()).getQualifier() != expression
|
||||
&& ((PsiNewExpression)expression.getParent()).getArrayInitializer() != expression) {
|
||||
// like in 'new String["s"]'
|
||||
myHolder.add(HighlightUtil.checkValidArrayAccessExpression(null, expression, type));
|
||||
myHolder.add(HighlightUtil.checkAssignability(PsiType.INT, expression.getType(), expression, expression));
|
||||
}
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightControlFlowUtil.checkCannotWriteToFinal(expression));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkVariableExpected(expression));
|
||||
@@ -900,7 +898,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!(parent instanceof PsiTypeParameter)) {
|
||||
myHolder.add(AnnotationsHighlightUtil.checkAnnotationDeclaration(parent, list));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkExtendsAllowed(list));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkImplementsAllowed(list));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkImplementsAllowed(list));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkClassExtendsOnlyOneClass(list));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkGenericCannotExtendException(list));
|
||||
}
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class ReplaceWithListAccessFix implements IntentionAction {
|
||||
private PsiArrayAccessExpression myArrayAccessExpression;
|
||||
|
||||
public ReplaceWithListAccessFix(PsiArrayAccessExpression arrayAccessExpression) {
|
||||
myArrayAccessExpression = arrayAccessExpression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return QuickFixBundle.message("replace.with.list.access.text");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!myArrayAccessExpression.isValid()) return false;
|
||||
if (!TypeConversionUtil.areTypesAssignmentCompatible(PsiType.INT, myArrayAccessExpression.getIndexExpression())) {
|
||||
return false;
|
||||
}
|
||||
final PsiElement parent = myArrayAccessExpression.getParent();
|
||||
if (parent instanceof PsiAssignmentExpression) {
|
||||
final PsiExpression lExpression = ((PsiAssignmentExpression)parent).getLExpression();
|
||||
if (lExpression.equals(myArrayAccessExpression) && !(parent.getParent() instanceof PsiExpressionStatement)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiExpression arrayExpression = myArrayAccessExpression.getArrayExpression();
|
||||
final PsiType type = arrayExpression.getType();
|
||||
final PsiType listType = createUtilListType(project);
|
||||
|
||||
if (type == null || listType == null) return false;
|
||||
|
||||
|
||||
return listType.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiType createUtilListType(@NotNull Project project) {
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass listClass = JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_UTIL_LIST, myArrayAccessExpression.getResolveScope());
|
||||
|
||||
if (listClass == null) return null;
|
||||
|
||||
final PsiElementFactory factory = facade.getElementFactory();
|
||||
return factory.createType(listClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
final PsiExpression arrayExpression = myArrayAccessExpression.getArrayExpression();
|
||||
final PsiExpression indexExpression = myArrayAccessExpression.getIndexExpression();
|
||||
|
||||
if (indexExpression == null) return;
|
||||
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
|
||||
|
||||
final PsiElement parent = myArrayAccessExpression.getParent();
|
||||
if (parent instanceof PsiAssignmentExpression) {
|
||||
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent;
|
||||
|
||||
final PsiExpression lExpression = assignmentExpression.getLExpression();
|
||||
final PsiExpression rExpression = assignmentExpression.getRExpression();
|
||||
if (lExpression.equals(myArrayAccessExpression) && parent.getParent() instanceof PsiExpressionStatement && rExpression != null) {
|
||||
replaceWithSet(factory, codeStyleManager, arrayExpression, indexExpression, rExpression, assignmentExpression);
|
||||
return;
|
||||
}
|
||||
}
|
||||
replaceWithGet(factory, codeStyleManager, arrayExpression, indexExpression, myArrayAccessExpression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiElement replaceWithGet(@NotNull PsiElementFactory factory,
|
||||
@NotNull CodeStyleManager codeStyleManager,
|
||||
@NotNull PsiExpression arrayExpression,
|
||||
@NotNull PsiExpression indexExpression,
|
||||
@NotNull PsiElement anchor) {
|
||||
|
||||
final PsiElement listAccess = factory.createExpressionFromText(
|
||||
arrayExpression.getText() + ".get(" + indexExpression.getText() + ")",
|
||||
anchor);
|
||||
return anchor.replace(codeStyleManager.reformat(listAccess));
|
||||
}
|
||||
|
||||
private static PsiElement replaceWithSet(@NotNull PsiElementFactory factory,
|
||||
@NotNull CodeStyleManager codeStyleManager,
|
||||
@NotNull PsiExpression arrayExpression,
|
||||
@NotNull PsiExpression indexExpression,
|
||||
@NotNull PsiExpression expression,
|
||||
@NotNull PsiElement anchor) {
|
||||
final PsiElement listAccess = factory.createExpressionFromText(
|
||||
arrayExpression.getText() + ".set(" + indexExpression.getText() + "," + expression.getText() + ")",
|
||||
anchor
|
||||
);
|
||||
return anchor.replace(codeStyleManager.reformat(listAccess));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
PsiCodeBlock body = method.getBody();
|
||||
if (body == null) return false;
|
||||
PsiStatement[] statements = body.getStatements();
|
||||
if (statements.length != 1) return false;
|
||||
if (statements.length == 0) return false;
|
||||
PsiStatement statement = statements[0];
|
||||
if (PropertyUtil.isSimplePropertyGetter(method)) {
|
||||
if (statement instanceof PsiReturnStatement) {
|
||||
@@ -275,6 +275,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
}
|
||||
}
|
||||
else if (PropertyUtil.isSimplePropertySetter(method)) {
|
||||
if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false;
|
||||
if (statement instanceof PsiExpressionStatement) {
|
||||
PsiExpression expr = ((PsiExpressionStatement)statement).getExpression();
|
||||
if (expr instanceof PsiAssignmentExpression) {
|
||||
@@ -651,7 +652,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar
|
||||
return psiParameter.getName();
|
||||
}
|
||||
}, ", ");
|
||||
@NonNls final String lambdas = "{" + params + " =>";
|
||||
@NonNls final String lambdas = "#{" + params + " ->";
|
||||
|
||||
final int closureStart = expression.getTextRange().getStartOffset();
|
||||
final int closureEnd = expression.getTextRange().getEndOffset();
|
||||
|
||||
@@ -263,7 +263,7 @@ public class OverrideImplementUtil {
|
||||
}
|
||||
if (results.isEmpty()) {
|
||||
PsiMethod method1 = GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);
|
||||
|
||||
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
|
||||
PsiMethod result = (PsiMethod)factory.createClass("Dummy").add(method1);
|
||||
if (result instanceof PsiAnnotationMethod) {
|
||||
@@ -304,6 +304,20 @@ public class OverrideImplementUtil {
|
||||
}
|
||||
}
|
||||
|
||||
//method type params are not allowed when overriding from raw type
|
||||
final PsiTypeParameterList list = result.getTypeParameterList();
|
||||
if (list != null) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
for (PsiClassType classType : aClass.getSuperTypes()) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(PsiUtil.resolveClassInType(classType), containingClass, true) && classType.isRaw()) {
|
||||
list.replace(JavaPsiFacade.getElementFactory(aClass.getProject()).createTypeParameterList());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
annotateOnOverrideImplement(result, aClass, method, insertOverrideIfPossible);
|
||||
|
||||
if (CodeStyleSettingsManager.getSettings(aClass.getProject()).REPEAT_SYNCHRONIZED && method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
|
||||
@@ -523,6 +537,7 @@ public class OverrideImplementUtil {
|
||||
final List<PsiMethodMember> selectedElements = chooser.getSelectedElements();
|
||||
if (selectedElements == null || selectedElements.isEmpty()) return;
|
||||
|
||||
LOG.assertTrue(aClass.isValid());
|
||||
new WriteCommandAction(project, aClass.getContainingFile()) {
|
||||
protected void run(final Result result) throws Throwable {
|
||||
overrideOrImplementMethodsInRightPlace(editor, aClass, selectedElements, chooser.isCopyJavadoc(), chooser.isInsertOverrideAnnotation());
|
||||
|
||||
@@ -86,7 +86,7 @@ public class MoveToPackageFix implements LocalQuickFix {
|
||||
}
|
||||
new MoveClassesOrPackagesProcessor(
|
||||
project,
|
||||
new PsiElement[]{((PsiJavaFile) myFile).getClasses()[0]},
|
||||
((PsiJavaFile) myFile).getClasses(),
|
||||
new SingleSourceRootMoveDestination(PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(directory)), directory), false,
|
||||
false,
|
||||
null).run();
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class ReplaceWithTernaryOperatorFix implements LocalQuickFix {
|
||||
private final String myText;
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionsBundle.message("inspection.replace.ternary.quickfix", myText);
|
||||
}
|
||||
|
||||
public ReplaceWithTernaryOperatorFix(@NotNull PsiExpression expressionToAssert) {
|
||||
myText = expressionToAssert.getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return InspectionsBundle.message("inspection.surround.if.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
if (!(element instanceof PsiExpression)) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression expression = (PsiExpression)element;
|
||||
|
||||
final PsiFile file = expression.getContainingFile();
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
final PsiConditionalExpression conditionalExpression = replaceWthConditionalExpression(project, myText + "!=null", expression, suggestDefaultValue(expression));
|
||||
|
||||
final PsiExpression elseExpression = conditionalExpression.getElseExpression();
|
||||
if (elseExpression != null) {
|
||||
selectInEditor(elseExpression);
|
||||
}
|
||||
}
|
||||
|
||||
private static void selectInEditor(@NotNull PsiElement element) {
|
||||
final Editor editor = PsiUtilBase.findEditor(element);
|
||||
if (editor == null) return;
|
||||
|
||||
final TextRange expressionRange = element.getTextRange();
|
||||
editor.getCaretModel().moveToOffset(expressionRange.getStartOffset());
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
editor.getSelectionModel().setSelection(expressionRange.getStartOffset(), expressionRange.getEndOffset());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiConditionalExpression replaceWthConditionalExpression(@NotNull Project project,
|
||||
@NotNull String condition,
|
||||
@NotNull PsiExpression expression,
|
||||
@NotNull String defaultValue) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
|
||||
final PsiElement parent = expression.getParent();
|
||||
final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)factory.createExpressionFromText(
|
||||
condition + " ? " + expression.getText() + " : " + defaultValue,
|
||||
parent
|
||||
);
|
||||
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
|
||||
return (PsiConditionalExpression)expression.replace( codeStyleManager.reformat(conditionalExpression));
|
||||
}
|
||||
|
||||
public static boolean isAvailable(@NotNull PsiExpression qualifier, @NotNull PsiExpression expression) {
|
||||
if (!qualifier.isValid() || qualifier.getText() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(expression.getParent() instanceof PsiExpressionStatement);
|
||||
}
|
||||
|
||||
private static String suggestDefaultValue(@NotNull PsiExpression expression) {
|
||||
PsiType type = expression.getType();
|
||||
return PsiTypesUtil.getDefaultValueOfType(type);
|
||||
}
|
||||
}
|
||||
@@ -81,8 +81,8 @@ public class SurroundWithIfFix implements LocalQuickFix {
|
||||
return InspectionsBundle.message("inspection.surround.if.family");
|
||||
}
|
||||
|
||||
public boolean isAvailable(PsiExpression qualifier) {
|
||||
if (!qualifier.isValid() || myText == null) {
|
||||
public static boolean isAvailable(PsiExpression qualifier) {
|
||||
if (!qualifier.isValid() || qualifier.getText() == null) {
|
||||
return false;
|
||||
}
|
||||
PsiStatement statement = PsiTreeUtil.getParentOfType(qualifier, PsiStatement.class);
|
||||
|
||||
@@ -68,20 +68,28 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
return new OptionsPanel();
|
||||
}
|
||||
|
||||
void test(@NotNull List l) {
|
||||
final List list = null;
|
||||
test(list);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
|
||||
return new JavaElementVisitor() {
|
||||
@Override public void visitField(PsiField field) {
|
||||
@Override
|
||||
public void visitField(PsiField field) {
|
||||
if (isNullLiteralExpression(field.getInitializer()) && NullableNotNullManager.isNotNull(field)) {
|
||||
holder.registerProblem(field.getInitializer(), InspectionsBundle.message("dataflow.message.initializing.field.with.null"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitMethod(PsiMethod method) {
|
||||
@Override
|
||||
public void visitMethod(PsiMethod method) {
|
||||
analyzeCodeBlock(method.getBody(), holder);
|
||||
}
|
||||
|
||||
@Override public void visitClassInitializer(PsiClassInitializer initializer) {
|
||||
@Override
|
||||
public void visitClassInitializer(PsiClassInitializer initializer) {
|
||||
analyzeCodeBlock(initializer.getBody(), holder);
|
||||
}
|
||||
};
|
||||
@@ -109,35 +117,38 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static LocalQuickFix[] createNPEFixes(PsiExpression qualifier) {
|
||||
if (qualifier != null &&
|
||||
!(qualifier instanceof PsiMethodCallExpression) &&
|
||||
!(qualifier instanceof PsiLiteralExpression && ((PsiLiteralExpression)qualifier).getValue() == null)) {
|
||||
try {
|
||||
PsiBinaryExpression binary = (PsiBinaryExpression)JavaPsiFacade.getInstance(qualifier.getProject()).getElementFactory()
|
||||
.createExpressionFromText("a != null", null);
|
||||
binary.getLOperand().replace(qualifier);
|
||||
List<LocalQuickFix> fixes = new SmartList<LocalQuickFix>();
|
||||
private static LocalQuickFix[] createNPEFixes(PsiExpression qualifier, PsiExpression expression) {
|
||||
if (qualifier == null || expression == null) return null;
|
||||
if (qualifier instanceof PsiMethodCallExpression) return null;
|
||||
if (qualifier instanceof PsiLiteralExpression && ((PsiLiteralExpression)qualifier).getValue() == null) return null;
|
||||
|
||||
if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) {
|
||||
fixes.add(new AddAssertStatementFix(binary));
|
||||
}
|
||||
SurroundWithIfFix ifFix = new SurroundWithIfFix(qualifier);
|
||||
if (ifFix.isAvailable(qualifier)) {
|
||||
fixes.add(ifFix);
|
||||
}
|
||||
return fixes.toArray(new LocalQuickFix[fixes.size()]);
|
||||
try {
|
||||
final List<LocalQuickFix> fixes = new SmartList<LocalQuickFix>();
|
||||
|
||||
if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) {
|
||||
final Project project = qualifier.getProject();
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
final PsiBinaryExpression binary = (PsiBinaryExpression)elementFactory.createExpressionFromText("a != null", null);
|
||||
binary.getLOperand().replace(qualifier);
|
||||
fixes.add(new AddAssertStatementFix(binary));
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
|
||||
if (SurroundWithIfFix.isAvailable(qualifier)) {
|
||||
fixes.add(new SurroundWithIfFix(qualifier));
|
||||
}
|
||||
if (ReplaceWithTernaryOperatorFix.isAvailable(qualifier, expression)) {
|
||||
fixes.add(new ReplaceWithTernaryOperatorFix(qualifier));
|
||||
}
|
||||
return fixes.toArray(new LocalQuickFix[fixes.size()]);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createDescription(StandardDataFlowRunner runner, ProblemsHolder holder, StandardInstructionVisitor visitor) {
|
||||
Pair<Set<Instruction>,Set<Instruction>> constConditions = runner.getConstConditionalExpressions();
|
||||
Pair<Set<Instruction>, Set<Instruction>> constConditions = runner.getConstConditionalExpressions();
|
||||
Set<Instruction> trueSet = constConditions.getFirst();
|
||||
Set<Instruction> falseSet = constConditions.getSecond();
|
||||
Set<Instruction> npeSet = runner.getNPEInstructions();
|
||||
@@ -164,7 +175,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
MethodCallInstruction mcInstruction = (MethodCallInstruction)instruction;
|
||||
if (mcInstruction.getCallExpression() instanceof PsiMethodCallExpression) {
|
||||
PsiMethodCallExpression callExpression = (PsiMethodCallExpression)mcInstruction.getCallExpression();
|
||||
LocalQuickFix[] fix = createNPEFixes(callExpression.getMethodExpression().getQualifierExpression());
|
||||
LocalQuickFix[] fix = createNPEFixes(callExpression.getMethodExpression().getQualifierExpression(), callExpression);
|
||||
|
||||
holder.registerProblem(callExpression,
|
||||
InspectionsBundle.message("dataflow.message.npe.method.invocation"),
|
||||
@@ -176,13 +187,13 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
PsiElement elementToAssert = frInstruction.getElementToAssert();
|
||||
PsiExpression expression = frInstruction.getExpression();
|
||||
if (expression instanceof PsiArrayAccessExpression) {
|
||||
LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert);
|
||||
LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert, expression);
|
||||
holder.registerProblem(expression,
|
||||
InspectionsBundle.message("dataflow.message.npe.array.access"),
|
||||
fix);
|
||||
}
|
||||
else {
|
||||
LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert);
|
||||
LocalQuickFix[] fix = createNPEFixes((PsiExpression)elementToAssert, expression);
|
||||
holder.registerProblem(elementToAssert,
|
||||
InspectionsBundle.message("dataflow.message.npe.field.access"),
|
||||
fix);
|
||||
@@ -207,7 +218,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(psiAnchor, true);
|
||||
holder.registerProblem(psiAnchor,
|
||||
InspectionsBundle.message(underBinary ? "dataflow.message.constant.condition.whenriched" : "dataflow.message.constant.condition", Boolean.toString(true)),
|
||||
localQuickFix==null?null:new LocalQuickFix[]{localQuickFix});
|
||||
localQuickFix == null ? null : new LocalQuickFix[]{localQuickFix});
|
||||
}
|
||||
}
|
||||
else if (psiAnchor instanceof PsiSwitchLabelStatement) {
|
||||
@@ -228,7 +239,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
final LocalQuickFix localQuickFix = createSimplifyBooleanExpressionFix(psiAnchor, evaluatesToTrue);
|
||||
holder.registerProblem(psiAnchor, InspectionsBundle.message(underBinary ? "dataflow.message.constant.condition.whenriched" : "dataflow.message.constant.condition",
|
||||
Boolean.toString(evaluatesToTrue)),
|
||||
localQuickFix == null ? null : new LocalQuickFix[]{localQuickFix});
|
||||
localQuickFix == null ? null : new LocalQuickFix[]{localQuickFix});
|
||||
}
|
||||
}
|
||||
reportedAnchors.add(psiAnchor);
|
||||
@@ -241,15 +252,15 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
final String text = isNullLiteralExpression(expr)
|
||||
? InspectionsBundle.message("dataflow.message.passing.null.argument")
|
||||
: InspectionsBundle.message("dataflow.message.passing.nullable.argument");
|
||||
LocalQuickFix[] fixes = createNPEFixes(expr);
|
||||
LocalQuickFix[] fixes = createNPEFixes(expr, expr);
|
||||
holder.registerProblem(expr, text, fixes);
|
||||
}
|
||||
|
||||
exprs = runner.getNullableAssignments();
|
||||
for (PsiExpression expr : exprs) {
|
||||
final String text = isNullLiteralExpression(expr)
|
||||
? InspectionsBundle.message("dataflow.message.assigning.null")
|
||||
: InspectionsBundle.message("dataflow.message.assigning.nullable");
|
||||
? InspectionsBundle.message("dataflow.message.assigning.null")
|
||||
: InspectionsBundle.message("dataflow.message.assigning.nullable");
|
||||
holder.registerProblem(expr, text);
|
||||
}
|
||||
|
||||
@@ -263,17 +274,16 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
final PsiExpression expr = statement.getReturnValue();
|
||||
if (runner.isInNotNullMethod()) {
|
||||
final String text = isNullLiteralExpression(expr)
|
||||
? InspectionsBundle.message("dataflow.message.return.null.from.notnull")
|
||||
: InspectionsBundle.message("dataflow.message.return.nullable.from.notnull");
|
||||
? InspectionsBundle.message("dataflow.message.return.null.from.notnull")
|
||||
: InspectionsBundle.message("dataflow.message.return.nullable.from.notnull");
|
||||
holder.registerProblem(expr, text);
|
||||
}
|
||||
else if (AnnotationUtil.isAnnotatingApplicable(statement)) {
|
||||
final String text = isNullLiteralExpression(expr)
|
||||
? InspectionsBundle.message("dataflow.message.return.null.from.notnullable")
|
||||
: InspectionsBundle.message("dataflow.message.return.nullable.from.notnullable");
|
||||
? InspectionsBundle.message("dataflow.message.return.null.from.notnullable")
|
||||
: InspectionsBundle.message("dataflow.message.return.nullable.from.notnullable");
|
||||
final NullableNotNullManager manager = NullableNotNullManager.getInstance(expr.getProject());
|
||||
holder.registerProblem(expr, text, new AnnotateMethodFix(manager.getDefaultNullable(), ArrayUtil.toStringArray(manager.getNotNulls())));
|
||||
|
||||
holder.registerProblem(expr, text, new AnnotateMethodFix(manager.getDefaultNullable(), ArrayUtil.toStringArray(manager.getNotNulls())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,7 +353,7 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
final PsiElement psiElement = descriptor.getPsiElement();
|
||||
if (psiElement == null) return;
|
||||
final SimplifyBooleanExpressionFix fix = createIntention(psiElement, value);
|
||||
if (fix==null) return;
|
||||
if (fix == null) return;
|
||||
try {
|
||||
LOG.assertTrue(psiElement.isValid());
|
||||
fix.invoke(project, null, psiElement.getContainingFile());
|
||||
@@ -480,8 +490,8 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
private static class DataFlowInstructionVisitor extends StandardInstructionVisitor {
|
||||
|
||||
protected void onAssigningToNotNullableVariable(AssignInstruction instruction, DataFlowRunner runner) {
|
||||
((StandardDataFlowRunner)runner).onAssigningToNotNullableVariable(instruction.getRExpression());
|
||||
}
|
||||
((StandardDataFlowRunner)runner).onAssigningToNotNullableVariable(instruction.getRExpression());
|
||||
}
|
||||
|
||||
protected void onNullableReturn(CheckReturnValueInstruction instruction, DataFlowRunner runner) {
|
||||
((StandardDataFlowRunner)runner).onNullableReturn(instruction.getReturn());
|
||||
@@ -496,15 +506,15 @@ public class DataFlowInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
|
||||
protected void onInstructionProducesNPE(MethodCallInstruction instruction, DataFlowRunner runner) {
|
||||
((StandardDataFlowRunner) runner).onInstructionProducesNPE(instruction);
|
||||
((StandardDataFlowRunner)runner).onInstructionProducesNPE(instruction);
|
||||
}
|
||||
|
||||
protected void onUnboxingNullable(MethodCallInstruction instruction, DataFlowRunner runner) {
|
||||
((StandardDataFlowRunner) runner).onUnboxingNullable(instruction.getContext());
|
||||
((StandardDataFlowRunner)runner).onUnboxingNullable(instruction.getContext());
|
||||
}
|
||||
|
||||
protected void onPassingNullParameter(DataFlowRunner runner, PsiExpression arg) {
|
||||
((StandardDataFlowRunner) runner).onPassingNullParameter(arg); // Parameters on stack are reverted.
|
||||
}
|
||||
((StandardDataFlowRunner)runner).onPassingNullParameter(arg); // Parameters on stack are reverted.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -44,10 +44,10 @@ public class SuspiciousCollectionsMethodCallsInspection extends BaseLocalInspect
|
||||
}
|
||||
|
||||
private static void setupPatternMethods(PsiManager manager,
|
||||
GlobalSearchScope searchScope,
|
||||
List<PsiMethod> patternMethods,
|
||||
IntArrayList indices) {
|
||||
final PsiClass collectionClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.util.Collection", searchScope);
|
||||
GlobalSearchScope searchScope,
|
||||
List<PsiMethod> patternMethods,
|
||||
IntArrayList indices) {
|
||||
final PsiClass collectionClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION, searchScope);
|
||||
PsiType[] javaLangObject = {PsiType.getJavaLangObject(manager, searchScope)};
|
||||
MethodSignature removeSignature = MethodSignatureUtil.createMethodSignature("remove", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
|
||||
if (collectionClass != null) {
|
||||
@@ -58,7 +58,7 @@ public class SuspiciousCollectionsMethodCallsInspection extends BaseLocalInspect
|
||||
addMethod(contains, 0, patternMethods, indices);
|
||||
}
|
||||
|
||||
final PsiClass listClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.util.List", searchScope);
|
||||
final PsiClass listClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, searchScope);
|
||||
if (listClass != null) {
|
||||
MethodSignature indexofSignature = MethodSignatureUtil.createMethodSignature("indexOf", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
|
||||
PsiMethod indexof = MethodSignatureUtil.findMethodBySignature(listClass, indexofSignature, false);
|
||||
@@ -68,7 +68,7 @@ public class SuspiciousCollectionsMethodCallsInspection extends BaseLocalInspect
|
||||
addMethod(lastindexof, 0, patternMethods, indices);
|
||||
}
|
||||
|
||||
final PsiClass mapClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.util.Map", searchScope);
|
||||
final PsiClass mapClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_MAP, searchScope);
|
||||
if (mapClass != null) {
|
||||
PsiMethod remove = MethodSignatureUtil.findMethodBySignature(mapClass, removeSignature, false);
|
||||
addMethod(remove, 0, patternMethods, indices);
|
||||
@@ -96,11 +96,13 @@ public class SuspiciousCollectionsMethodCallsInspection extends BaseLocalInspect
|
||||
final List<PsiMethod> patternMethods = new ArrayList<PsiMethod>();
|
||||
final IntArrayList indices = new IntArrayList();
|
||||
return new JavaElementVisitor() {
|
||||
@Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
|
||||
@Override
|
||||
public void visitReferenceExpression(final PsiReferenceExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
@Override public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
|
||||
super.visitMethodCallExpression(methodCall);
|
||||
final String message = getSuspiciousMethodCallMessage(methodCall, REPORT_CONVERTIBLE_METHOD_CALLS, patternMethods, indices
|
||||
);
|
||||
|
||||
@@ -72,25 +72,26 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
|
||||
|
||||
@Override
|
||||
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
|
||||
String navigateInfo = null;
|
||||
if (element instanceof PsiClass) {
|
||||
return generateClassInfo((PsiClass)element);
|
||||
navigateInfo = generateClassInfo((PsiClass)element);
|
||||
}
|
||||
else if (element instanceof PsiMethod) {
|
||||
return generateMethodInfo((PsiMethod)element, calcSubstitutor(originalElement));
|
||||
navigateInfo = generateMethodInfo((PsiMethod)element, calcSubstitutor(originalElement));
|
||||
}
|
||||
else if (element instanceof PsiField) {
|
||||
return generateFieldInfo((PsiField)element, calcSubstitutor(originalElement));
|
||||
navigateInfo = generateFieldInfo((PsiField)element, calcSubstitutor(originalElement));
|
||||
}
|
||||
else if (element instanceof PsiVariable) {
|
||||
return generateVariableInfo((PsiVariable)element);
|
||||
navigateInfo = generateVariableInfo((PsiVariable)element);
|
||||
}
|
||||
else if (element instanceof PsiPackage) {
|
||||
return generatePackageInfo((PsiPackage)element);
|
||||
navigateInfo = generatePackageInfo((PsiPackage)element);
|
||||
}
|
||||
else if (element instanceof BeanPropertyElement) {
|
||||
return generateMethodInfo(((BeanPropertyElement) element).getMethod(), PsiSubstitutor.EMPTY);
|
||||
navigateInfo = generateMethodInfo(((BeanPropertyElement) element).getMethod(), PsiSubstitutor.EMPTY);
|
||||
}
|
||||
return null;
|
||||
return StringUtil.escapeXml(StringUtil.unescapeXml(navigateInfo));
|
||||
}
|
||||
|
||||
private static PsiSubstitutor calcSubstitutor(PsiElement originalElement) {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.psi.filters;
|
||||
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiAnnotationParameterList;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNameValuePair;
|
||||
import com.intellij.util.ReflectionCache;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class AnnotationParameterFilter implements ElementFilter{
|
||||
private final Class<? extends PsiElement> myClass;
|
||||
@NonNls private final String myParameterName;
|
||||
private final String myAnnotationQualifiedName;
|
||||
|
||||
|
||||
public AnnotationParameterFilter(final Class<? extends PsiElement> elementClass,
|
||||
final String annotationQualifiedName,
|
||||
@NonNls final String parameterName) {
|
||||
myAnnotationQualifiedName = annotationQualifiedName;
|
||||
myClass = elementClass;
|
||||
myParameterName = parameterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptable(Object element, PsiElement context) {
|
||||
final PsiElement parent = ((PsiElement)element).getParent();
|
||||
if (parent instanceof PsiNameValuePair) {
|
||||
final PsiNameValuePair pair = (PsiNameValuePair)parent;
|
||||
final String name = pair.getName();
|
||||
if (myParameterName.equals(name) || name == null && "value".equals(myParameterName)) {
|
||||
final PsiElement psiElement = pair.getParent();
|
||||
if (psiElement instanceof PsiAnnotationParameterList) {
|
||||
final PsiElement grandParent = psiElement.getParent();
|
||||
if (grandParent instanceof PsiAnnotation) {
|
||||
if (myAnnotationQualifiedName.equals(((PsiAnnotation)grandParent).getQualifiedName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClassAcceptable(Class hintClass) {
|
||||
return ReflectionCache.isAssignable(myClass, hintClass);
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -21,7 +21,6 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -35,12 +34,10 @@ public class JavaReflectionCompletionConfidence extends CompletionConfidence {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldSkipAutopopup(@Nullable PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
if (contextElement != null) {
|
||||
final PsiElement literal = contextElement.getParent();
|
||||
if (literal != null && JavaReflectionReferenceContributor.PATTERN.accepts(literal)) {
|
||||
return ThreeState.NO;
|
||||
}
|
||||
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
final PsiElement literal = contextElement.getParent();
|
||||
if (literal != null && JavaReflectionReferenceContributor.PATTERN.accepts(literal)) {
|
||||
return ThreeState.NO;
|
||||
}
|
||||
return super.shouldSkipAutopopup(contextElement, psiFile, offset);
|
||||
}
|
||||
|
||||
@@ -318,10 +318,10 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
List<PsiFile> files = new ArrayList<PsiFile>();
|
||||
for (final Map.Entry<PsiFile, PsiClass[]> entry : fileToClasses.entrySet()) {
|
||||
final PsiFile psiFile = entry.getKey();
|
||||
if (psiFile instanceof PsiClassOwner) {
|
||||
final PsiClass[] sources = entry.getValue();
|
||||
if (psiFile instanceof PsiClassOwner && sources != null) {
|
||||
final PsiFile createdFile = copy(psiFile, targetDirectory, copyClassName, map == null ? null : map.get(psiFile), choice);
|
||||
if (createdFile == null) return null;
|
||||
final PsiClass[] sources = entry.getValue();
|
||||
for (final PsiClass destination : ((PsiClassOwner)createdFile).getClasses()) {
|
||||
if (destination instanceof SyntheticElement) {
|
||||
continue;
|
||||
|
||||
+3
-26
@@ -40,11 +40,11 @@ import com.intellij.refactoring.util.classMembers.MemberInfoStorage;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -63,39 +63,16 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori
|
||||
myTargetClasses = targetClasses;
|
||||
MemberInfoStorage memberInfoStorage = new MemberInfoStorage(mySuperClass, new MemberInfo.Filter<PsiMember>() {
|
||||
public boolean includeMember(PsiMember element) {
|
||||
return true;
|
||||
return !(element instanceof PsiClass) || PsiTreeUtil.isAncestor(mySuperClass, element, true);
|
||||
}
|
||||
});
|
||||
List<MemberInfo> members = memberInfoStorage.getClassMemberInfos(mySuperClass);
|
||||
for (MemberInfo member : members) {
|
||||
member.setChecked(true);
|
||||
}
|
||||
members = appendSuperRefs(members);
|
||||
myMemberInfos = members.toArray(new MemberInfo[members.size()]);
|
||||
}
|
||||
|
||||
private List<MemberInfo> appendSuperRefs(List<MemberInfo> members) {
|
||||
if (!mySuperClass.isInterface()) {
|
||||
PsiReferenceList extendsList = mySuperClass.getExtendsList();
|
||||
if (extendsList != null && extendsList.getReferenceElements().length > 0) {
|
||||
PsiElement resolve = extendsList.getReferenceElements()[0].resolve();
|
||||
if (resolve instanceof PsiClass) {
|
||||
members = new ArrayList<MemberInfo>(members);
|
||||
|
||||
MemberInfo memberInfo = new MemberInfo((PsiMember)resolve, true, extendsList) {
|
||||
{
|
||||
overrides = false;
|
||||
}
|
||||
};
|
||||
|
||||
memberInfo.setChecked(true);
|
||||
members.add(memberInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected UsageViewDescriptor createUsageViewDescriptor(final UsageInfo[] usages) {
|
||||
return new InlineSuperClassUsageViewDescriptor(mySuperClass);
|
||||
|
||||
+5
-5
@@ -21,22 +21,22 @@
|
||||
package com.intellij.refactoring.inlineSuperClass.usageInfo;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteExtendsClassUsageInfo;
|
||||
import com.intellij.refactoring.util.FixableUsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
public class ReplaceExtendsListUsageInfo extends FixableUsageInfo {
|
||||
private final SafeDeleteExtendsClassUsageInfo mySafeDeleteUsageInfo;
|
||||
|
||||
public ReplaceExtendsListUsageInfo(PsiJavaCodeReferenceElement element, final PsiClass superClass, final PsiClass targetClass) {
|
||||
super(element);
|
||||
|
||||
mySafeDeleteUsageInfo = new SafeDeleteExtendsClassUsageInfo(element, superClass, targetClass);
|
||||
}
|
||||
|
||||
public void fixUsage() throws IncorrectOperationException {
|
||||
final PsiElement element = getElement();
|
||||
if (element != null) {
|
||||
element.delete();
|
||||
if (mySafeDeleteUsageInfo.isSafeDelete()) {
|
||||
mySafeDeleteUsageInfo.deleteElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class InplaceIntroduceFieldPopup extends AbstractInplaceIntroduceFieldPop
|
||||
final boolean forStatic,
|
||||
@NotNull final PsiClass parentClass) {
|
||||
return IntroduceFieldDialog.
|
||||
createGenerator(forStatic, localVariable, initializer, localVariable != null, null, parentClass).
|
||||
createGenerator(forStatic, localVariable, initializer, localVariable != null, null, parentClass, parentClass.getProject()).
|
||||
getSuggestedNameInfo(defaultType);
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -180,7 +180,7 @@ class IntroduceFieldDialog extends DialogWrapper {
|
||||
|
||||
myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField,
|
||||
createGenerator(myWillBeDeclaredStatic, myLocalVariable, myInitializerExpression, myIsInvokedOnDeclaration, myEnteredName,
|
||||
myParentClass));
|
||||
myParentClass, myProject));
|
||||
myNameSuggestionsManager.setLabelsFor(type, namePrompt);
|
||||
|
||||
return panel;
|
||||
@@ -203,10 +203,12 @@ class IntroduceFieldDialog extends DialogWrapper {
|
||||
static NameSuggestionsGenerator createGenerator(final boolean willBeDeclaredStatic,
|
||||
final PsiLocalVariable localVariable,
|
||||
final PsiExpression initializerExpression,
|
||||
final boolean isInvokedOnDeclaration, @Nullable final String enteredName, final PsiClass parentClass) {
|
||||
final boolean isInvokedOnDeclaration,
|
||||
@Nullable final String enteredName,
|
||||
final PsiClass parentClass,
|
||||
final Project project) {
|
||||
return new NameSuggestionsGenerator() {
|
||||
private final JavaCodeStyleManager myCodeStyleManager = JavaCodeStyleManager.getInstance(localVariable != null ? localVariable.getProject()
|
||||
: initializerExpression.getProject());
|
||||
private final JavaCodeStyleManager myCodeStyleManager = JavaCodeStyleManager.getInstance(project);
|
||||
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
|
||||
VariableKind variableKind = willBeDeclaredStatic ? VariableKind.STATIC_FIELD : VariableKind.FIELD;
|
||||
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ public class MoveClassesOrPackagesUtil {
|
||||
if (!moveDestination.equals(file.getContainingDirectory())) {
|
||||
LOG.assertTrue(file.getVirtualFile() != null, aClass);
|
||||
MoveFilesOrDirectoriesUtil.doMoveFile(file, moveDestination);
|
||||
if (file instanceof PsiClassOwner && newPackage != null) {
|
||||
if (file instanceof PsiClassOwner && newPackage != null && !JspPsiUtil.isInJspFile(file)) {
|
||||
((PsiClassOwner)file).setPackageName(newPackage.getQualifiedName());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -59,9 +59,13 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
|
||||
final TypeView right = new TypeView(rExpression);
|
||||
|
||||
final IElementType sign = expression.getOperationTokenType();
|
||||
final PsiType ltype = left.getType();
|
||||
final PsiType rtype = right.getType();
|
||||
if (ltype == null || rtype == null) return;
|
||||
|
||||
if (sign != JavaTokenType.EQ) {
|
||||
final IElementType binaryOperator = TypeConversionUtil.convertEQtoOperation(sign);
|
||||
if (!TypeConversionUtil.isBinaryOperatorApplicable(binaryOperator, left.getType(), right.getType(), false)) {
|
||||
if (!TypeConversionUtil.isBinaryOperatorApplicable(binaryOperator, ltype, rtype, false)) {
|
||||
if (left.isChanged()) {
|
||||
findConversionOrFail(expression, lExpression, left.getTypePair());
|
||||
}
|
||||
@@ -77,11 +81,11 @@ class TypeMigrationStatementProcessor extends JavaRecursiveElementVisitor {
|
||||
break;
|
||||
|
||||
case TypeInfection.LEFT_INFECTED:
|
||||
myLabeler.migrateExpressionType(rExpression, left.getType(), myStatement, TypeConversionUtil.isAssignable(left.getType(), right.getType()), true);
|
||||
myLabeler.migrateExpressionType(rExpression, ltype, myStatement, TypeConversionUtil.isAssignable(ltype, rtype), true);
|
||||
break;
|
||||
|
||||
case TypeInfection.RIGHT_INFECTED:
|
||||
myLabeler.migrateExpressionType(lExpression, right.getType(), myStatement, TypeConversionUtil.isAssignable(left.getType(), right.getType()), false);
|
||||
myLabeler.migrateExpressionType(lExpression, rtype, myStatement, TypeConversionUtil.isAssignable(ltype, rtype), false);
|
||||
break;
|
||||
|
||||
case TypeInfection.BOTH_INFECTED:
|
||||
|
||||
@@ -36,11 +36,11 @@ import java.util.Set;
|
||||
*/
|
||||
public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
public UsageType getUsageType(final PsiElement element) {
|
||||
return getUsageType(element, null);
|
||||
return getUsageType(element, UsageTarget.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsageType getUsageType(PsiElement element, @Nullable UsageTarget[] targets) {
|
||||
public UsageType getUsageType(PsiElement element, @NotNull UsageTarget[] targets) {
|
||||
UsageType classUsageType = getClassUsageType(element, targets);
|
||||
if (classUsageType != null) return classUsageType;
|
||||
|
||||
@@ -108,8 +108,10 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
}
|
||||
|
||||
private static boolean haveCommonSuperMethod(@NotNull PsiMethod m1, @NotNull PsiMethod m2) {
|
||||
final Queue<PsiMethod> supers1Q = new ArrayDeque<PsiMethod>(); supers1Q.add(m1);
|
||||
final Queue<PsiMethod> supers2Q = new ArrayDeque<PsiMethod>(); supers2Q.add(m2);
|
||||
final Queue<PsiMethod> supers1Q = new ArrayDeque<PsiMethod>();
|
||||
supers1Q.add(m1);
|
||||
final Queue<PsiMethod> supers2Q = new ArrayDeque<PsiMethod>();
|
||||
supers2Q.add(m2);
|
||||
Set<PsiMethod> supers1 = new THashSet<PsiMethod>();
|
||||
Set<PsiMethod> supers2 = new THashSet<PsiMethod>();
|
||||
while (true) {
|
||||
@@ -138,7 +140,7 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (me1 == null && me2==null) break;
|
||||
if (me1 == null && me2 == null) break;
|
||||
}
|
||||
return false;
|
||||
/*
|
||||
@@ -154,9 +156,11 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UsageType getClassUsageType(PsiElement element, @Nullable UsageTarget[] targets) {
|
||||
private static UsageType getClassUsageType(@NotNull PsiElement element, @NotNull UsageTarget[] targets) {
|
||||
if (element.getParent() instanceof PsiAnnotation &&
|
||||
element == ((PsiAnnotation)element.getParent()).getNameReferenceElement()) return UsageType.ANNOTATION;
|
||||
element == ((PsiAnnotation)element.getParent()).getNameReferenceElement()) {
|
||||
return UsageType.ANNOTATION;
|
||||
}
|
||||
|
||||
if (PsiTreeUtil.getParentOfType(element, PsiImportStatement.class, false) != null) return UsageType.CLASS_IMPORT;
|
||||
PsiReferenceList referenceList = PsiTreeUtil.getParentOfType(element, PsiReferenceList.class);
|
||||
@@ -215,12 +219,15 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
|
||||
final PsiNewExpression psiNewExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
|
||||
if (psiNewExpression != null) {
|
||||
final PsiJavaCodeReferenceElement classReference = psiNewExpression.getClassReference();
|
||||
final PsiJavaCodeReferenceElement classReference = psiNewExpression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null && PsiTreeUtil.isAncestor(classReference, element, false)) {
|
||||
if (isAnonymousClassOf(psiNewExpression.getAnonymousClass(), targets)) {
|
||||
return UsageType.CLASS_ANONYMOUS_NEW_OPERATOR;
|
||||
}
|
||||
if (isInnerClassOf(classReference, targets)) {
|
||||
return UsageType.CLASS_INNER_NEW_OPERATOR;
|
||||
}
|
||||
if (psiNewExpression.getArrayDimensions().length > 0) {
|
||||
if (isNewArrayCreation(psiNewExpression)) {
|
||||
return UsageType.CLASS_NEW_ARRAY;
|
||||
}
|
||||
return UsageType.CLASS_NEW_OPERATOR;
|
||||
@@ -230,20 +237,33 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isInnerClassOf(PsiJavaCodeReferenceElement classReference, @Nullable UsageTarget[] targets) {
|
||||
if (targets == null) {
|
||||
private static boolean isNewArrayCreation(@NotNull PsiNewExpression expression){
|
||||
return expression.getArrayDimensions().length > 0 || expression.getArrayInitializer() != null;
|
||||
}
|
||||
|
||||
private static boolean isAnonymousClassOf(@Nullable PsiAnonymousClass anonymousClass, @NotNull UsageTarget[] targets) {
|
||||
if (anonymousClass == null) {
|
||||
return false;
|
||||
}
|
||||
PsiElement qualifier = classReference.getQualifier();
|
||||
|
||||
return qualifiesToTargetClasses(anonymousClass.getBaseClassReference(), targets);
|
||||
}
|
||||
|
||||
private static boolean isInnerClassOf(PsiJavaCodeReferenceElement classReference, @NotNull UsageTarget[] targets) {
|
||||
final PsiElement qualifier = classReference.getQualifier();
|
||||
if (qualifier instanceof PsiJavaCodeReferenceElement) {
|
||||
for (UsageTarget target : targets) {
|
||||
if (target instanceof PsiElementUsageTarget) {
|
||||
PsiElement element = ((PsiElementUsageTarget)target).getElement();
|
||||
if (element instanceof PsiClass) {
|
||||
String name = target.getName();
|
||||
if (Comparing.equal(((PsiJavaCodeReferenceElement)qualifier).getReferenceName(), name)) {
|
||||
return true;
|
||||
}
|
||||
return qualifiesToTargetClasses((PsiJavaCodeReferenceElement)qualifier, targets);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean qualifiesToTargetClasses(@NotNull PsiJavaCodeReferenceElement qualifier, @NotNull UsageTarget[] targets) {
|
||||
for (UsageTarget target : targets) {
|
||||
if (target instanceof PsiElementUsageTarget) {
|
||||
PsiElement element = ((PsiElementUsageTarget)target).getElement();
|
||||
if (element instanceof PsiClass) {
|
||||
if (Comparing.equal(qualifier.getReferenceName(), target.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+45
-38
@@ -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,7 +22,10 @@ import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiSuperExpressionImpl extends ExpressionPsiElement implements PsiSuperExpression, Constants {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiSuperExpressionImpl");
|
||||
@@ -38,17 +41,20 @@ public class PsiSuperExpressionImpl extends ExpressionPsiElement implements PsiS
|
||||
|
||||
@Override
|
||||
public PsiType getType() {
|
||||
PsiJavaCodeReferenceElement qualifier = getQualifier();
|
||||
if (qualifier != null){
|
||||
final PsiJavaCodeReferenceElement qualifier = getQualifier();
|
||||
if (qualifier != null) {
|
||||
final PsiElement aClass = qualifier.resolve();
|
||||
return aClass instanceof PsiClass ? getSuperType((PsiClass)aClass) : null;
|
||||
if (!(aClass instanceof PsiClass)) return null;
|
||||
return getSuperType((PsiClass)aClass, PsiUtil.isLanguageLevel8OrHigher(this));
|
||||
}
|
||||
for(PsiElement scope = getContext(); scope != null; scope = scope.getContext()){
|
||||
if (scope instanceof PsiClass){
|
||||
PsiClass aClass = (PsiClass)scope;
|
||||
return getSuperType(aClass);
|
||||
|
||||
for (PsiElement scope = getContext(); scope != null; scope = scope.getContext()) {
|
||||
if (scope instanceof PsiClass) {
|
||||
final PsiClass aClass = (PsiClass)scope;
|
||||
return getSuperType(aClass, false);
|
||||
}
|
||||
if (scope instanceof PsiExpressionList && scope.getParent() instanceof PsiAnonymousClass){
|
||||
if (scope instanceof PsiExpressionList && scope.getParent() instanceof PsiAnonymousClass) {
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
scope = scope.getParent();
|
||||
}
|
||||
else if (scope instanceof JavaCodeFragment) {
|
||||
@@ -56,55 +62,56 @@ public class PsiSuperExpressionImpl extends ExpressionPsiElement implements PsiS
|
||||
if (fragmentSuperType != null) return fragmentSuperType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private PsiType getSuperType(PsiClass aClass) {
|
||||
@Nullable
|
||||
private PsiType getSuperType(PsiClass aClass, boolean checkImmediateSuperInterfaces) {
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) return null;
|
||||
|
||||
final PsiClass containingClass = checkImmediateSuperInterfaces ? PsiTreeUtil.getParentOfType(this, PsiClass.class) : null;
|
||||
if (containingClass != null) {
|
||||
final PsiClassType[] superTypes;
|
||||
if (containingClass.isInterface()) {
|
||||
superTypes = containingClass.getExtendsListTypes();
|
||||
}
|
||||
else if (containingClass instanceof PsiAnonymousClass) {
|
||||
superTypes = new PsiClassType[]{((PsiAnonymousClass)containingClass).getBaseClassType()};
|
||||
}
|
||||
else {
|
||||
superTypes = containingClass.getImplementsListTypes();
|
||||
}
|
||||
|
||||
for (PsiClassType superType : superTypes) {
|
||||
final PsiClass superClass = superType.resolve();
|
||||
if (superClass != null && superClass.isInterface() && aClass.equals(superClass)) return superType;
|
||||
}
|
||||
}
|
||||
|
||||
if (aClass.isInterface()) {
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
return facade.getElementFactory().createType(facade.findClass("java.lang.Object", getResolveScope()));
|
||||
return PsiType.getJavaLangObject(getManager(), getResolveScope());
|
||||
}
|
||||
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
final PsiClassType baseClassType = ((PsiAnonymousClass)aClass).getBaseClassType();
|
||||
final PsiClass psiClass = baseClassType.resolve();
|
||||
if(psiClass != null && !psiClass.isInterface()){
|
||||
return baseClassType;
|
||||
}
|
||||
|
||||
return PsiType.getJavaLangObject(getManager(), getResolveScope());
|
||||
return psiClass != null && !psiClass.isInterface() ? baseClassType : PsiType.getJavaLangObject(getManager(), getResolveScope());
|
||||
}
|
||||
|
||||
if ("java.lang.Object".equals(aClass.getQualifiedName())) return null;
|
||||
PsiClassType[] superTypes = aClass.getExtendsListTypes();
|
||||
if (superTypes.length == 0) {
|
||||
JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
final PsiClass javaLangObject = facade.findClass("java.lang.Object", getResolveScope());
|
||||
if (javaLangObject != null) {
|
||||
return facade.getElementFactory().createType(javaLangObject);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return superTypes[0];
|
||||
final PsiClassType[] superTypes = aClass.getExtendsListTypes();
|
||||
return superTypes.length == 0 ? PsiType.getJavaLangObject(getManager(), getResolveScope()) : superTypes[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode findChildByRole(int role) {
|
||||
LOG.assertTrue(ChildRole.isUnique(role));
|
||||
switch(role){
|
||||
switch (role) {
|
||||
default:
|
||||
return null;
|
||||
|
||||
case ChildRole.QUALIFIER:
|
||||
if (getFirstChildNode().getElementType() == JAVA_CODE_REFERENCE){
|
||||
return getFirstChildNode();
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
return getFirstChildNode().getElementType() == JAVA_CODE_REFERENCE ? getFirstChildNode() : null;
|
||||
|
||||
case ChildRole.DOT:
|
||||
return findChildByType(DOT);
|
||||
|
||||
@@ -198,6 +198,7 @@ not.a.statement=Not a statement
|
||||
incompatible.types=Incompatible types. Found: ''{1}'', required: ''{0}''
|
||||
valid.switch.selector.types=byte, char, short or int
|
||||
dot.expected.after.super.or.this='.' expected
|
||||
unqualified.super.disallowed=Unqualified super reference is not allowed in extension method
|
||||
|
||||
non.static.symbol.referenced.from.static.context=Non-static {0} ''{1}'' cannot be referenced from a static context
|
||||
private.symbol=''{0}'' has private access in ''{1}''
|
||||
@@ -272,9 +273,6 @@ unclosed.char.literal=Unclosed character literal
|
||||
illegal.escape.character.in.string.literal=Illegal escape character in string literal
|
||||
floating.point.number.too.large=Floating point number too large
|
||||
floating.point.number.too.small=Floating point number too small
|
||||
hex.FP.literals.not.supported=Hexadecimal floating point literals are only supported in JDK 5 or higher
|
||||
binary.literals.not.supported=Binary literals are only supported in JDK 7 or higher
|
||||
underscores.in.literals.not.supported=Underscores in literals are only supported in JDK 7 or higher
|
||||
|
||||
import.statement.identifier.or.asterisk.expected.=Identifier or '*' expected
|
||||
|
||||
@@ -348,8 +346,11 @@ feature.annotations=Annotations
|
||||
feature.static.imports=Static imports
|
||||
feature.for.each=For-each loops
|
||||
feature.varargs=Variable arity methods
|
||||
feature.hex.fp.literals=Hexadecimal floating point literals
|
||||
feature.diamond.types=Diamond types
|
||||
feature.multi.catch=Multi-catches
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.binary.literals=Binary literals
|
||||
feature.underscores.in.literals=Underscores in literals
|
||||
feature.extension.methods=Extension methods
|
||||
insufficient.language.level={0} are not supported at this language level
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
x = (ProceedingJoinPoint<? extends <caret>>
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
x = (ProceedingJoinPoint<? ext<caret>>
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
public class Xxx {
|
||||
|
||||
<T extends <caret>
|
||||
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
public class Xxx {
|
||||
|
||||
<T ext<caret>
|
||||
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class Foo<T extends<caret> A> {
|
||||
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class Foo<T ext<caret> A> {
|
||||
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
try {
|
||||
|
||||
} finally {<caret>
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
try {
|
||||
|
||||
} final<caret> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
try {
|
||||
|
||||
} finally {
|
||||
<caret>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
try {
|
||||
|
||||
} final<caret>
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
if (null<caret>)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
if (nu<caret>)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class Null {
|
||||
public static void main(String[] argv) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(nu<caret>);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class Null {
|
||||
public static void main(String[] argv) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(Null.nu<caret>);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class Null {
|
||||
public static void main(String[] argv) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(Null.nu<caret>);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class Null {
|
||||
public static void main(String[] argv) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(null);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static Object main() {
|
||||
return null<caret>
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static Object main() {
|
||||
return nu<caret>
|
||||
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
boolean b = true<caret>
|
||||
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main() {
|
||||
boolean b = tr<caret>
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
public class A{
|
||||
public void method(){
|
||||
try{
|
||||
String str = "";
|
||||
}
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
public class A{
|
||||
public void method(){
|
||||
try{
|
||||
String str = "";
|
||||
}
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class A{
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 A{
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
interface Foo {
|
||||
String foo() def<caret>
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
interface Foo {
|
||||
String foo() default <caret>
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
class x3 <caret>
|
||||
@@ -1,3 +0,0 @@
|
||||
class A{
|
||||
void <T extends <caret>>foo(){}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class A{
|
||||
void <T e<caret>>foo(){}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class A{
|
||||
void <T extends String, V extends <caret>>foo(){}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class A{
|
||||
void <T extends String, V e<caret>>foo(){}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
class A{
|
||||
{
|
||||
Collection<? extends <caret>>
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
class A{
|
||||
{
|
||||
Collection<? ex<caret>>
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
class BBB extends <caret>
|
||||
@@ -1,5 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
interface CCC{}
|
||||
|
||||
class BBB extends <caret>
|
||||
@@ -1,5 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
interface CCC{}
|
||||
|
||||
class BBB implements <caret>
|
||||
@@ -1,3 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
interface BBB extends <caret>
|
||||
@@ -1,3 +0,0 @@
|
||||
interface AAA{}
|
||||
|
||||
interface BBB extends Runnable, <caret>
|
||||
@@ -1,3 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
class BBB extends AAA implements <caret>
|
||||
@@ -1,3 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
class BBB extends AAA i<caret>
|
||||
@@ -1,4 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
class BBB extends AAA implements <caret> {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
class AAA{}
|
||||
|
||||
class BBB extends AAA i<caret> {
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
interface AAAA extends <caret>
|
||||
@@ -1 +0,0 @@
|
||||
interface AAAA e<caret>
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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 x3 <caret>
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 A{
|
||||
void <T e<caret>>foo(){}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 A{
|
||||
void <T extends <caret>>foo(){}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 A{
|
||||
void <T extends String, V e<caret>>foo(){}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 A{
|
||||
void <T extends String, V extends <caret>>foo(){}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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 A{
|
||||
{
|
||||
Collection<? ex<caret>>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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 A{
|
||||
{
|
||||
Collection<? extends <caret>>
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user