mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -151,7 +151,7 @@ if [ "$IS_EAP" = "true" ]; then
|
||||
OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'`
|
||||
AGENT_LIB="yjpagent-$OS_NAME$BITS"
|
||||
if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
|
||||
AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,delay=10000,sessionname=@@system_selector@@"
|
||||
AGENT="-agentlib:$AGENT_LIB=disablealloc,delay=10000,sessionname=@@system_selector@@"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -142,11 +142,11 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
Element state = new Element("state");
|
||||
XmlSerializer.serializeInto(myState, state, new SkipDefaultValuesSerializationFilters() {
|
||||
@Override
|
||||
protected boolean accepts(@NotNull Accessor accessor, @NotNull Object bean, @Nullable Object beanValue) {
|
||||
public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
|
||||
if (myState.compilerWasSpecified && "DEFAULT_COMPILER".equals(accessor.getName())) {
|
||||
return true;
|
||||
}
|
||||
return super.accepts(accessor, bean, beanValue);
|
||||
return super.accepts(accessor, bean);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -93,6 +93,7 @@ import io.netty.handler.codec.protobuf.ProtobufDecoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufEncoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.ide.PooledThreadExecutor;
|
||||
@@ -999,6 +1000,9 @@ public class BuildManager implements ApplicationComponent{
|
||||
cmdLine.addParameter("-Didea.case.sensitive.fs=" + isFSCaseSensitive);
|
||||
}
|
||||
|
||||
// this will make netty initialization faster on some systems
|
||||
cmdLine.addParameter("-Dio.netty.initialSeedUniquifier=" + ThreadLocalRandom.getInitialSeedUniquifier());
|
||||
|
||||
boolean isProfilingMode = false;
|
||||
final String additionalOptions = config.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
|
||||
if (!StringUtil.isEmpty(additionalOptions)) {
|
||||
@@ -1013,7 +1017,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
if (isProfilingMode) {
|
||||
cmdLine.addParameter("-agentlib:yjpagent=disablej2ee,disablealloc,delay=10000,sessionname=ExternalBuild");
|
||||
cmdLine.addParameter("-agentlib:yjpagent=disablealloc,delay=10000,sessionname=ExternalBuild");
|
||||
}
|
||||
|
||||
// debugging
|
||||
|
||||
+33
-35
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,13 +29,11 @@ import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.compiler.options.ExcludesConfiguration;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -143,41 +141,41 @@ public class InspectionValidatorWrapper implements Validator {
|
||||
return ProcessingItem.EMPTY_ARRAY;
|
||||
}
|
||||
final ExcludesConfiguration excludesConfiguration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
|
||||
final List<ProcessingItem> items = new ReadAction<List<ProcessingItem>>() {
|
||||
@Override
|
||||
protected void run(final Result<List<ProcessingItem>> result) {
|
||||
final CompileScope compileScope = context.getCompileScope();
|
||||
if (!myValidator.isAvailableOnScope(compileScope)) return;
|
||||
final List<ProcessingItem> items =
|
||||
DumbService.getInstance(project).runReadActionInSmartMode(new Computable<List<ProcessingItem>>() {
|
||||
@Override
|
||||
public List<ProcessingItem> compute() {
|
||||
final CompileScope compileScope = context.getCompileScope();
|
||||
if (!myValidator.isAvailableOnScope(compileScope)) return null;
|
||||
|
||||
final ArrayList<ProcessingItem> items = new ArrayList<ProcessingItem>();
|
||||
final ArrayList<ProcessingItem> items = new ArrayList<ProcessingItem>();
|
||||
|
||||
final Processor<VirtualFile> processor = new ReadActionProcessor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean processInReadAction(VirtualFile file) {
|
||||
if (!file.isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (myCompilerManager.isExcludedFromCompilation(file) ||
|
||||
excludesConfiguration.isExcluded(file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Module module = context.getModuleByFile(file);
|
||||
if (module != null) {
|
||||
final PsiFile psiFile = myPsiManager.findFile(file);
|
||||
if (psiFile != null) {
|
||||
items.add(new MyValidatorProcessingItem(psiFile));
|
||||
final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
|
||||
@Override
|
||||
public boolean process(VirtualFile file) {
|
||||
if (!file.isValid()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ContainerUtil.process(myValidator.getFilesToProcess(myPsiManager.getProject(), context), processor);
|
||||
|
||||
result.setResult(items);
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
if (myCompilerManager.isExcludedFromCompilation(file) ||
|
||||
excludesConfiguration.isExcluded(file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Module module = context.getModuleByFile(file);
|
||||
if (module != null) {
|
||||
final PsiFile psiFile = myPsiManager.findFile(file);
|
||||
if (psiFile != null) {
|
||||
items.add(new MyValidatorProcessingItem(psiFile));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ContainerUtil.process(myValidator.getFilesToProcess(myPsiManager.getProject(), context), processor);
|
||||
return items;
|
||||
}
|
||||
});
|
||||
if (items == null) return ProcessingItem.EMPTY_ARRAY;
|
||||
|
||||
return items.toArray(new ProcessingItem[items.size()]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -78,7 +78,7 @@ public class AddToWatchActionHandler extends DebuggerActionHandler {
|
||||
if(session == null) {
|
||||
return;
|
||||
}
|
||||
final MainWatchPanel watchPanel = DebuggerPanelsManager.getInstance(debuggerContext.getProject()).getWatchPanel();
|
||||
final MainWatchPanel watchPanel = null;// DebuggerPanelsManager.getInstance(debuggerContext.getProject()).getWatchPanel();
|
||||
|
||||
if(watchPanel == null) {
|
||||
return;
|
||||
|
||||
@@ -1,143 +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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Class EvaluateAction
|
||||
* @author Jeka
|
||||
*/
|
||||
package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.ExpressionEvaluationDialog;
|
||||
import com.intellij.debugger.ui.StatementEvaluationDialog;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeExpression;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKeys;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EvaluateActionHandler extends DebuggerActionHandler {
|
||||
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
|
||||
DebuggerContextImpl context = DebuggerAction.getDebuggerContext(event.getDataContext());
|
||||
|
||||
if(context != null) {
|
||||
DebuggerSession debuggerSession = context.getDebuggerSession();
|
||||
return debuggerSession != null && debuggerSession.isPaused();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void perform(@NotNull final Project project, final AnActionEvent event) {
|
||||
final DataContext dataContext = event.getDataContext();
|
||||
final DebuggerContextImpl context = DebuggerAction.getDebuggerContext(dataContext);
|
||||
|
||||
if(context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Editor editor = event.getData(DataKeys.EDITOR);
|
||||
|
||||
TextWithImports editorText = DebuggerUtilsEx.getEditorText(editor);
|
||||
if (editorText == null) {
|
||||
final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(dataContext);
|
||||
final String actionName = event.getPresentation().getText();
|
||||
|
||||
if (selectedNode != null && selectedNode.getDescriptor() instanceof ValueDescriptorImpl) {
|
||||
context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {
|
||||
public void threadAction() {
|
||||
try {
|
||||
final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(selectedNode, context);
|
||||
DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
|
||||
public void run() {
|
||||
showEvaluationDialog(project, evaluationText);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (final EvaluateException e1) {
|
||||
DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
|
||||
public void run() {
|
||||
Messages.showErrorDialog(project, e1.getMessage(), actionName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void commandCancelled() {
|
||||
DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
|
||||
public void run() {
|
||||
if(selectedNode.getDescriptor() instanceof WatchItemDescriptor) {
|
||||
try {
|
||||
TextWithImports editorText = DebuggerTreeNodeExpression.createEvaluationText(selectedNode, context);
|
||||
showEvaluationDialog(project, editorText);
|
||||
}
|
||||
catch (EvaluateException e1) {
|
||||
Messages.showErrorDialog(project, e1.getMessage(), actionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
showEvaluationDialog(project, editorText);
|
||||
}
|
||||
|
||||
public static void showEvaluationDialog(Project project, TextWithImports defaultExpression, String dialogType) {
|
||||
if(defaultExpression == null) {
|
||||
defaultExpression = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
|
||||
}
|
||||
|
||||
CodeFragmentKind kind = DebuggerSettings.EVALUATE_FRAGMENT.equals(dialogType) ? CodeFragmentKind.CODE_BLOCK : CodeFragmentKind.EXPRESSION;
|
||||
|
||||
DebuggerSettings.getInstance().EVALUATION_DIALOG_TYPE = dialogType;
|
||||
TextWithImportsImpl text = new TextWithImportsImpl(kind, defaultExpression.getText(), defaultExpression.getImports(), defaultExpression.getFileType());
|
||||
|
||||
final DialogWrapper dialog;
|
||||
if(DebuggerSettings.EVALUATE_FRAGMENT.equals(dialogType)) {
|
||||
dialog = new StatementEvaluationDialog(project, text);
|
||||
}
|
||||
else {
|
||||
dialog = new ExpressionEvaluationDialog(project, text);
|
||||
}
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showEvaluationDialog(Project project, TextWithImports text) {
|
||||
showEvaluationDialog(project, text, DebuggerSettings.getInstance().EVALUATION_DIALOG_TYPE);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +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.debugger.actions;
|
||||
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerStateManager;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.ui.DebuggerPanelsManager;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataConstants;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* User: lex
|
||||
* Date: Sep 26, 2003
|
||||
* Time: 7:45:21 PM
|
||||
*/
|
||||
public class ShowFrameAction extends GotoFrameSourceAction {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
super.actionPerformed(e);
|
||||
DebuggerStateManager stateManager = getContextManager(e.getDataContext());
|
||||
DebuggerContextImpl context = stateManager.getContext();
|
||||
|
||||
if(context != null) {
|
||||
DebuggerPanelsManager.getInstance(context.getProject()).showFramePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.debugger.ui.DebuggerSessionTab;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
@@ -70,7 +70,7 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp
|
||||
public void run() {
|
||||
XDebugSession xSession = session.getXDebugSession();
|
||||
if (xSession != null) {
|
||||
DebuggerSessionTab.addThreadDump(project, threads, xSession.getUI(), session);
|
||||
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -27,7 +27,6 @@ import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.debugger.requests.Requestor;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.DebuggerPanelsManager;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
@@ -452,7 +451,6 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
DebuggerInvocationUtil.invokeAndWait(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DebuggerPanelsManager.getInstance(getProject()).toFront(mySession);
|
||||
final String displayName = requestor instanceof Breakpoint? ((Breakpoint)requestor).getDisplayName() : requestor.getClass().getSimpleName();
|
||||
final String message = DebuggerBundle.message("error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage());
|
||||
considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -1098,7 +1098,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
throw (RuntimeException)exception[0];
|
||||
}
|
||||
else {
|
||||
LOG.assertTrue(false);
|
||||
LOG.error("Unexpected exception " + exception[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,14 @@ import com.intellij.debugger.requests.Requestor;
|
||||
import com.intellij.debugger.ui.CompletionEditor;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
|
||||
import com.intellij.execution.filters.ExceptionFilters;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -47,6 +54,9 @@ import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.ui.classFilter.ClassFilter;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.unscramble.ThreadDumpPanel;
|
||||
import com.intellij.unscramble.ThreadState;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
@@ -399,6 +409,43 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int myThreadDumpsCount = 0;
|
||||
private static int myCurrentThreadDumpId = 1;
|
||||
|
||||
private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump";
|
||||
|
||||
public static void addThreadDump(Project project, List<ThreadState> threads, final RunnerLayoutUi ui, DebuggerSession session) {
|
||||
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
|
||||
consoleBuilder.filters(ExceptionFilters.getFilters(session.getSearchScope()));
|
||||
final ConsoleView consoleView = consoleBuilder.getConsole();
|
||||
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
|
||||
consoleView.allowHeavyFilters();
|
||||
final ThreadDumpPanel panel = new ThreadDumpPanel(project, consoleView, toolbarActions, threads);
|
||||
|
||||
final String id = THREAD_DUMP_CONTENT_PREFIX + " #" + myCurrentThreadDumpId;
|
||||
final Content content = ui.createContent(id, panel, id, null, null);
|
||||
content.setCloseable(true);
|
||||
content.setDescription("Thread Dump");
|
||||
ui.addContent(content);
|
||||
ui.selectAndFocus(content, true, true);
|
||||
myThreadDumpsCount++;
|
||||
myCurrentThreadDumpId++;
|
||||
Disposer.register(content, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myThreadDumpsCount--;
|
||||
if (myThreadDumpsCount == 0) {
|
||||
myCurrentThreadDumpId = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
Disposer.register(content, consoleView);
|
||||
ui.selectAndFocus(content, true, false);
|
||||
if (threads.size() > 0) {
|
||||
panel.selectStackFrame(0);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract DebuggerTreeNode getSelectedNode (DataContext context);
|
||||
|
||||
public abstract EvaluatorBuilder getEvaluatorBuilder();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -84,6 +84,22 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
throw new EvaluateException(error.getMessage(), error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
if (!super.isValid()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (myStackFrame != null) {
|
||||
myStackFrame.location(); //extra check if jdi frame is valid
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidStackFrameException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearCaches() {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -24,10 +24,8 @@ import com.intellij.debugger.engine.JavaDebugProcess;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.impl.DebuggerStateManager;
|
||||
import com.intellij.debugger.ui.impl.MainWatchPanel;
|
||||
import com.intellij.debugger.ui.tree.render.BatchEvaluator;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
@@ -39,9 +37,8 @@ import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.execution.ui.RunContentWithExecutorListener;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.xdebugger.XDebugProcess;
|
||||
import com.intellij.xdebugger.XDebugProcessStarter;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
@@ -50,43 +47,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DebuggerPanelsManager implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.DebuggerPanelsManager");
|
||||
|
||||
private final Project myProject;
|
||||
private final ExecutionManager myExecutionManager;
|
||||
|
||||
//private final PositionHighlighter myEditorManager;
|
||||
//private final HashMap<ProcessHandler, DebuggerSessionTab> mySessionTabs = new HashMap<ProcessHandler, DebuggerSessionTab>();
|
||||
|
||||
public DebuggerPanelsManager(Project project, final EditorColorsManager colorsManager, ExecutionManager executionManager) {
|
||||
public DebuggerPanelsManager(Project project) {
|
||||
myProject = project;
|
||||
myExecutionManager = executionManager;
|
||||
|
||||
//myEditorManager = new PositionHighlighter(myProject, getContextManager());
|
||||
//
|
||||
//final EditorColorsListener myColorsListener = new EditorColorsListener() {
|
||||
// public void globalSchemeChange(EditorColorsScheme scheme) {
|
||||
// myEditorManager.updateContextPointDescription();
|
||||
// }
|
||||
//};
|
||||
//colorsManager.addEditorColorsListener(myColorsListener);
|
||||
//Disposer.register(project, new Disposable() {
|
||||
// public void dispose() {
|
||||
// colorsManager.removeEditorColorsListener(myColorsListener);
|
||||
// }
|
||||
//});
|
||||
//
|
||||
//getContextManager().addListener(new DebuggerContextListener() {
|
||||
// public void changeEvent(final DebuggerContextImpl newContext, int event) {
|
||||
// if (event == DebuggerSession.EVENT_PAUSE) {
|
||||
// DebuggerInvocationUtil.invokeLater(myProject, new Runnable() {
|
||||
// public void run() {
|
||||
// toFront(newContext.getDebuggerSession());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
}
|
||||
|
||||
private DebuggerStateManager getContextManager() {
|
||||
@@ -195,48 +159,12 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
return project.getComponent(DebuggerPanelsManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MainWatchPanel getWatchPanel() {
|
||||
DebuggerSessionTab sessionTab = getSessionTab();
|
||||
return sessionTab != null ? sessionTab.getWatchPanel() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DebuggerSessionTab getSessionTab() {
|
||||
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
|
||||
return getSessionTab(context.getDebuggerSession());
|
||||
}
|
||||
|
||||
public void showFramePanel() {
|
||||
DebuggerSessionTab sessionTab = getSessionTab();
|
||||
if (sessionTab != null) {
|
||||
sessionTab.showFramePanel();
|
||||
}
|
||||
}
|
||||
|
||||
public void toFront(DebuggerSession session) {
|
||||
DebuggerSessionTab sessionTab = getSessionTab(session);
|
||||
if (sessionTab != null) {
|
||||
sessionTab.toFront(true, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static DebuggerSession getSession(Project project, RunContentDescriptor descriptor) {
|
||||
for (XDebugSession session : XDebuggerManager.getInstance(project).getDebugSessions()) {
|
||||
if (session.getRunContentDescriptor().equals(descriptor)) {
|
||||
XDebugProcess process = session.getDebugProcess();
|
||||
if (process instanceof JavaDebugProcess) {
|
||||
return ((JavaDebugProcess)process).getDebuggerSession();
|
||||
}
|
||||
for (JavaDebugProcess process : XDebuggerManager.getInstance(project).getDebugProcesses(JavaDebugProcess.class)) {
|
||||
if (Comparing.equal(process.getProcessHandler(), descriptor.getProcessHandler())) {
|
||||
return process.getDebuggerSession();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private DebuggerSessionTab getSessionTab(DebuggerSession session) {
|
||||
//return session != null ? getSessionTab(session.getProcess().getExecutionResult().getProcessHandler()) : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,12 +36,8 @@ import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import com.intellij.execution.filters.ExceptionFilters;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ExecutionConsoleEx;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.execution.ui.layout.PlaceInGrid;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
@@ -56,8 +52,6 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManagerAdapter;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
|
||||
import com.intellij.unscramble.ThreadDumpPanel;
|
||||
import com.intellij.unscramble.ThreadState;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
import com.intellij.xdebugger.impl.settings.XDebuggerSettingsManager;
|
||||
@@ -68,7 +62,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.List;
|
||||
|
||||
public class DebuggerSessionTab extends DebuggerSessionTabBase implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(DebuggerSessionTab.class);
|
||||
@@ -84,7 +77,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
private final DebugUIEnvironment myDebugUIEnvironment;
|
||||
|
||||
private final ThreadsPanel myThreadsPanel;
|
||||
private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump";
|
||||
|
||||
public DebuggerSessionTab(final Project project, final String sessionName, @NotNull final DebugUIEnvironment environment,
|
||||
@NotNull DebuggerSession debuggerSession) {
|
||||
@@ -447,51 +439,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
myUi.selectAndFocus(myUi.findContent(DebuggerContentInfo.FRAME_CONTENT), true, false);
|
||||
}
|
||||
|
||||
private static int myThreadDumpsCount = 0;
|
||||
private static int myCurrentThreadDumpId = 1;
|
||||
|
||||
public static void addThreadDump(Project project, List<ThreadState> threads, final RunnerLayoutUi ui, DebuggerSession session) {
|
||||
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
|
||||
consoleBuilder.filters(ExceptionFilters.getFilters(session.getSearchScope()));
|
||||
final ConsoleView consoleView = consoleBuilder.getConsole();
|
||||
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
|
||||
consoleView.allowHeavyFilters();
|
||||
final ThreadDumpPanel panel = new ThreadDumpPanel(project, consoleView, toolbarActions, threads);
|
||||
|
||||
final String id = createThreadDumpContentId();
|
||||
final Content content = ui.createContent(id, panel, id, null, null);
|
||||
content.setCloseable(true);
|
||||
content.setDescription("Thread Dump");
|
||||
ui.addContent(content);
|
||||
ui.selectAndFocus(content, true, true);
|
||||
myThreadDumpsCount += 1;
|
||||
myCurrentThreadDumpId += 1;
|
||||
//Disposer.register(this, new Disposable() {
|
||||
// @Override
|
||||
// public void dispose() {
|
||||
// ui.removeContent(content, true);
|
||||
// }
|
||||
//});
|
||||
Disposer.register(content, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myThreadDumpsCount -= 1;
|
||||
if (myThreadDumpsCount == 0) {
|
||||
myCurrentThreadDumpId = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
Disposer.register(content, consoleView);
|
||||
ui.selectAndFocus(content, true, false);
|
||||
if (threads.size() > 0) {
|
||||
panel.selectStackFrame(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static String createThreadDumpContentId() {
|
||||
return THREAD_DUMP_CONTENT_PREFIX + " #" + myCurrentThreadDumpId;
|
||||
}
|
||||
|
||||
private class MyDebuggerStateManager extends DebuggerStateManager {
|
||||
@Override
|
||||
public void fireStateChanged(DebuggerContextImpl newContext, int event) {
|
||||
|
||||
@@ -1,190 +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.debugger.ui;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.HelpID;
|
||||
import com.intellij.debugger.actions.EvaluateActionHandler;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentFactory;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.ex.AbstractDelegatingToRootTraversalPolicy;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class ExpressionEvaluationDialog extends EvaluationDialog {
|
||||
|
||||
public ExpressionEvaluationDialog(Project project, TextWithImports defaultExpression) {
|
||||
super(project, defaultExpression);
|
||||
setTitle(DebuggerBundle.message("evaluate.expression.dialog.title"));
|
||||
|
||||
final KeyStroke expressionStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK);
|
||||
final KeyStroke resultStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK);
|
||||
|
||||
final JRootPane rootPane = getRootPane();
|
||||
|
||||
final AnAction anAction = new AnAction() {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
getExpressionCombo().requestFocus();
|
||||
}
|
||||
};
|
||||
anAction.registerCustomShortcutSet(new CustomShortcutSet(expressionStroke), rootPane);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
anAction.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
final AnAction anAction2 = new AnAction() {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
getEvaluationPanel().getWatchTree().requestFocus();
|
||||
}
|
||||
};
|
||||
anAction2.registerCustomShortcutSet(new CustomShortcutSet(resultStroke), rootPane);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
anAction2.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
protected DebuggerExpressionComboBox createEditor(final CodeFragmentFactory factory) {
|
||||
return new DebuggerExpressionComboBox(getProject(), PositionUtil.getContextElement(getDebuggerContext()), "evaluation", factory);
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
final JPanel exprPanel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, 0));
|
||||
exprPanel.add(new JLabel(DebuggerBundle.message("label.evaluate.dialog.expression")), BorderLayout.WEST);
|
||||
exprPanel.add(getExpressionCombo(), BorderLayout.CENTER);
|
||||
final JBLabel help = new JBLabel("Press Enter to Evaluate or Control+Enter to evaluate and add to the Watches", SwingConstants.RIGHT);
|
||||
help.setBorder(IdeBorderFactory.createEmptyBorder(2,0,6,0));
|
||||
help.setComponentStyle(UIUtil.ComponentStyle.SMALL);
|
||||
help.setFontColor(UIUtil.FontColor.BRIGHTER);
|
||||
exprPanel.add(help, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
final JPanel resultPanel = new JPanel(new BorderLayout());
|
||||
//resultPanel.add(new JLabel(DebuggerBundle.message("label.evaluate.dialog.result")), BorderLayout.NORTH);
|
||||
resultPanel.add(getEvaluationPanel(), BorderLayout.CENTER);
|
||||
|
||||
panel.add(exprPanel, BorderLayout.NORTH);
|
||||
panel.add(resultPanel, BorderLayout.CENTER);
|
||||
|
||||
panel.setFocusTraversalPolicyProvider(true);
|
||||
panel.setFocusTraversalPolicy(new AbstractDelegatingToRootTraversalPolicy() {
|
||||
@Override
|
||||
public Component getComponentBefore(Container aContainer, Component aComponent) {
|
||||
boolean focusExpressionCombo = isParent(aComponent, getEvaluationPanel());
|
||||
return focusExpressionCombo ? getExpressionCombo().getEditorComponent() : super.getComponentBefore(aContainer, aComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponentAfter(Container aContainer, Component aComponent) {
|
||||
boolean focusEvaluationPanel = isParent(aComponent, exprPanel);
|
||||
return focusEvaluationPanel ? getEvaluationPanel().getTree() : super.getComponentAfter(aContainer, aComponent);
|
||||
}
|
||||
|
||||
private boolean isParent(@NotNull Component component, @NotNull Container parent) {
|
||||
for (Component c = component; c != null; c = c.getParent()) {
|
||||
if (c == parent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected void initDialogData(TextWithImports text) {
|
||||
super.initDialogData(text);
|
||||
getExpressionCombo().selectAll();
|
||||
}
|
||||
|
||||
private DebuggerExpressionComboBox getExpressionCombo() {
|
||||
return (DebuggerExpressionComboBox)getEditor();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Action[] createActions() {
|
||||
return new Action[] { getOKAction(), getCancelAction(), new SwitchAction(), getHelpAction() } ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions();
|
||||
myOKAction = new OkAction(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
super.actionPerformed(e);
|
||||
if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
|
||||
addCurrentExpressionToWatches();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void addCurrentExpressionToWatches() {
|
||||
final DebuggerSessionTab tab = DebuggerPanelsManager.getInstance(getProject()).getSessionTab();
|
||||
if (tab != null) {
|
||||
final TextWithImports evaluate = getCodeToEvaluate();
|
||||
if (evaluate != null) {
|
||||
tab.getWatchPanel().getWatchTree().addWatch(evaluate, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void doHelpAction() {
|
||||
HelpManager.getInstance().invokeHelp(HelpID.EVALUATE);
|
||||
}
|
||||
|
||||
private class SwitchAction extends AbstractAction {
|
||||
public SwitchAction() {
|
||||
putValue(Action.NAME, DebuggerBundle.message("action.evaluate.expression.dialog.switch.mode.description"));
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final TextWithImports text = getEditor().getText();
|
||||
doCancelAction();
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
public void run() {
|
||||
EvaluateActionHandler.showEvaluationDialog(getProject(), text, DebuggerSettings.EVALUATE_FRAGMENT);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,221 +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.debugger.ui;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.HelpID;
|
||||
import com.intellij.debugger.actions.EvaluateActionHandler;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentFactory;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.DimensionService;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* @author lex
|
||||
*/
|
||||
public class StatementEvaluationDialog extends EvaluationDialog{
|
||||
private final JPanel myPanel;
|
||||
private final Action mySwitchAction = new SwitchAction();
|
||||
private static final @NonNls String STATEMENT_EDITOR_DIMENSION_KEY = "#com.intellij.debugger.ui.StatementEvaluationDialog.StatementEditor";
|
||||
private static final @NonNls String EVALUATION_PANEL_DIMENSION_KEY = "#com.intellij.debugger.ui.StatementEvaluationDialog.EvaluationPanel";
|
||||
|
||||
public StatementEvaluationDialog(final Project project, TextWithImports text) {
|
||||
super(project, text);
|
||||
setTitle(DebuggerBundle.message("evaluate.statement.dialog.title"));
|
||||
myPanel = new JPanel(new BorderLayout());
|
||||
|
||||
final Splitter splitter = new Splitter(true);
|
||||
splitter.setHonorComponentsMinimumSize(true);
|
||||
|
||||
final JPanel editorPanel = new JPanel(new GridBagLayout());
|
||||
|
||||
final JLabel statementsLabel = new JLabel(DebuggerBundle.message("label.evaluation.dialog.statements"));
|
||||
editorPanel.add(statementsLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
editorPanel.add(getStatementEditor(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 0, 0, 0), 0, 0));
|
||||
|
||||
splitter.setFirstComponent(editorPanel);
|
||||
|
||||
final MyEvaluationPanel evaluationPanel = getEvaluationPanel();
|
||||
final JPanel ep = new JPanel(new BorderLayout());
|
||||
//final JLabel resultLabel = new JLabel(DebuggerBundle.message("label.evaluate.dialog.result"));
|
||||
//ep.add(resultLabel, BorderLayout.NORTH);
|
||||
ep.add(evaluationPanel, BorderLayout.CENTER);
|
||||
splitter.setSecondComponent(ep);
|
||||
final Dimension statementSize = DimensionService.getInstance().getSize(STATEMENT_EDITOR_DIMENSION_KEY, project);
|
||||
final Dimension evaluationSize = DimensionService.getInstance().getSize(EVALUATION_PANEL_DIMENSION_KEY, project);
|
||||
if (statementSize != null && evaluationSize != null) {
|
||||
final float proportion = (float)statementSize.height / (float)(statementSize.height + evaluationSize.height);
|
||||
splitter.setProportion(proportion);
|
||||
}
|
||||
myPanel.add(splitter, BorderLayout.CENTER);
|
||||
|
||||
setDebuggerContext(getDebuggerContext());
|
||||
|
||||
final KeyStroke codeFragment = KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.ALT_MASK);
|
||||
final KeyStroke resultStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_MASK);
|
||||
final KeyStroke altEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_MASK);
|
||||
|
||||
final JRootPane rootPane = getRootPane();
|
||||
final AnAction toStatementAction = new AnAction() {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
getStatementEditor().requestFocus();
|
||||
}
|
||||
};
|
||||
toStatementAction.registerCustomShortcutSet(new CustomShortcutSet(codeFragment), rootPane);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
toStatementAction.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
final AnAction toEvaluationAction = new AnAction() {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
getEvaluationPanel().getWatchTree().requestFocus();
|
||||
}
|
||||
};
|
||||
toEvaluationAction.registerCustomShortcutSet(new CustomShortcutSet(resultStroke), rootPane);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
toEvaluationAction.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
final AnAction okAction = new AnAction() {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
doOKAction();
|
||||
}
|
||||
};
|
||||
okAction.registerCustomShortcutSet(new CustomShortcutSet(altEnter), rootPane);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
okAction.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
final DebuggerEditorImpl editor = getEditor();
|
||||
final DocumentAdapter docListener = new DocumentAdapter() {
|
||||
public void documentChanged(final DocumentEvent e) {
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
public void run() {
|
||||
updateSwitchButton(e.getDocument());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
editor.addDocumentListener(docListener);
|
||||
addDisposeRunnable(new Runnable() {
|
||||
public void run() {
|
||||
editor.removeDocumentListener(docListener);
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void updateSwitchButton(Document document) {
|
||||
PsiDocumentManager.getInstance(getProject()).commitDocument(document);
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(getProject()).getPsiFile(document);
|
||||
if (psiFile == null) {
|
||||
return;
|
||||
}
|
||||
PsiElement[] children = psiFile.getChildren();
|
||||
int nonWhite = 0;
|
||||
for (PsiElement child : children) {
|
||||
if (!(child instanceof PsiWhiteSpace)) {
|
||||
nonWhite++;
|
||||
if (nonWhite > 1) {
|
||||
mySwitchAction.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mySwitchAction.setEnabled(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Action[] createActions(){
|
||||
return new Action[]{getOKAction(), getCancelAction(), mySwitchAction, getHelpAction() };
|
||||
}
|
||||
|
||||
protected void doHelpAction() {
|
||||
HelpManager.getInstance().invokeHelp(HelpID.EVALUATE);
|
||||
}
|
||||
|
||||
protected DebuggerEditorImpl createEditor(final CodeFragmentFactory factory) {
|
||||
return new DebuggerStatementEditor(getProject(), PositionUtil.getContextElement(getDebuggerContext()), "evaluation", factory);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
try {
|
||||
final DebuggerEditorImpl editor = getEditor();
|
||||
final DimensionService dimensionService = DimensionService.getInstance();
|
||||
dimensionService.setSize(STATEMENT_EDITOR_DIMENSION_KEY, editor.getSize(null), getProject());
|
||||
dimensionService.setSize(EVALUATION_PANEL_DIMENSION_KEY, getEvaluationPanel().getSize(), getProject());
|
||||
}
|
||||
finally {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
private DebuggerStatementEditor getStatementEditor() {
|
||||
return (DebuggerStatementEditor)getEditor();
|
||||
}
|
||||
|
||||
private class SwitchAction extends AbstractAction {
|
||||
public SwitchAction() {
|
||||
putValue(NAME, DebuggerBundle.message("action.evaluate.statement.dialog.switch.mode.description"));
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final TextWithImports text = getEditor().getText();
|
||||
doCancelAction();
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
public void run() {
|
||||
EvaluateActionHandler.showEvaluationDialog(getProject(), text, DebuggerSettings.EVALUATE_EXPRESSION);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -307,7 +307,10 @@ public abstract class SourcePosition implements Navigatable{
|
||||
}
|
||||
|
||||
public static SourcePosition createFromElement(PsiElement element) {
|
||||
final PsiElement navigationElement = element.getNavigationElement();
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
PsiElement navigationElement = element.getNavigationElement();
|
||||
final SmartPsiElementPointer<PsiElement> pointer =
|
||||
SmartPointerManager.getInstance(navigationElement.getProject()).createSmartPsiElementPointer(navigationElement);
|
||||
final PsiFile psiFile;
|
||||
if (JspPsiUtil.isInJspFile(navigationElement)) {
|
||||
psiFile = JspPsiUtil.getJspFile(navigationElement);
|
||||
@@ -318,12 +321,19 @@ public abstract class SourcePosition implements Navigatable{
|
||||
return new SourcePositionCache(psiFile) {
|
||||
@Override
|
||||
protected PsiElement calcPsiElement() {
|
||||
return navigationElement;
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
return pointer.getElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int calcOffset() {
|
||||
return navigationElement.getTextOffset();
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
|
||||
@Override
|
||||
public Integer compute() {
|
||||
PsiElement elem = pointer.getElement();
|
||||
return elem != null ? elem.getTextOffset() : -1;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+12
-12
@@ -86,20 +86,20 @@ public class IncreaseLanguageLevelFix implements IntentionAction {
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
|
||||
final LanguageLevel moduleLevel = module == null ? null : LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
|
||||
if (moduleLevel != null && isLanguageLevelAcceptable(project, module, myLevel)) {
|
||||
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLevel);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (moduleLevel != null && isLanguageLevelAcceptable(project, module, myLevel)) {
|
||||
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLevel);
|
||||
rootModel.commit();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(myLevel);
|
||||
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.INSTANCE, false, true);
|
||||
}
|
||||
else {
|
||||
LanguageLevelProjectExtension.getInstance(project).setLanguageLevel(myLevel);
|
||||
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.INSTANCE, false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+6
-5
@@ -263,13 +263,14 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
|
||||
|
||||
final PsiMethod psiMethod = methodCall.resolveMethod();
|
||||
JavaResolveResult result = methodCall.resolveMethodGenerics();
|
||||
final PsiMethod psiMethod = (PsiMethod)result.getElement();
|
||||
if (psiMethod == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
|
||||
final String qualifierByMethodCall = getQualifierTextByMethodCall(methodCall, functionalInterfaceType, parameters, psiMethod);
|
||||
final String qualifierByMethodCall = getQualifierTextByMethodCall(methodCall, functionalInterfaceType, parameters, psiMethod, result.getSubstitutor());
|
||||
if (qualifierByMethodCall != null) {
|
||||
return qualifierByMethodCall + "::" + ((PsiMethodCallExpression)element).getTypeArgumentList().getText() + methodExpression.getReferenceName();
|
||||
}
|
||||
@@ -324,7 +325,8 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
private static String getQualifierTextByMethodCall(final PsiMethodCallExpression methodCall,
|
||||
final PsiType functionalInterfaceType,
|
||||
final PsiParameter[] parameters,
|
||||
final PsiMethod psiMethod) {
|
||||
final PsiMethod psiMethod,
|
||||
final PsiSubstitutor substitutor) {
|
||||
|
||||
final PsiExpression qualifierExpression = methodCall.getMethodExpression().getQualifierExpression();
|
||||
|
||||
@@ -332,7 +334,7 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
LOG.assertTrue(containingClass != null);
|
||||
|
||||
if (qualifierExpression != null) {
|
||||
boolean isReceiverType = PsiMethodReferenceUtil.isReceiverType(functionalInterfaceType, containingClass, psiMethod);
|
||||
boolean isReceiverType = PsiMethodReferenceUtil.isReceiverType(PsiMethodReferenceUtil.getFirstParameterType(functionalInterfaceType, methodCall), containingClass, substitutor);
|
||||
return isReceiverType ? composeReceiverQualifierText(parameters, psiMethod, containingClass, qualifierExpression)
|
||||
: qualifierExpression.getText();
|
||||
}
|
||||
@@ -422,7 +424,6 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
if (lambdaExpression == null) return;
|
||||
PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
|
||||
if (functionalInterfaceType == null || !functionalInterfaceType.isValid()) return;
|
||||
String functionalTypeText = functionalInterfaceType.getCanonicalText();
|
||||
final String methodRefText = createMethodReferenceText(element, functionalInterfaceType,
|
||||
lambdaExpression.getParameterList().getParameters());
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 25-Jan-2008
|
||||
*/
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.LineMarkersPass;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodSeparatorProvider extends FileSeparatorProvider {
|
||||
@Override
|
||||
public List<LineMarkerInfo> getFileSeparators(final PsiFile file, final Document document, @Nullable final Editor editor) {
|
||||
final List<LineMarkerInfo> result = new ArrayList<LineMarkerInfo>();
|
||||
LineMarkersPass pass = new LineMarkersPass(file.getProject(), file, editor, document, file.getTextRange());
|
||||
for (LineMarkerInfo lineMarkerInfo : pass.queryLineMarkers()) {
|
||||
if (lineMarkerInfo.separatorColor != null) {
|
||||
result.add(lineMarkerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<LineMarkerInfo>() {
|
||||
public int compare(final LineMarkerInfo i1, final LineMarkerInfo i2) {
|
||||
return i1.startOffset - i2.startOffset;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class CodeInsightUtil {
|
||||
if (parent == null) return PsiElement.EMPTY_ARRAY;
|
||||
while (true) {
|
||||
if (parent instanceof PsiStatement) {
|
||||
if (!(element1 instanceof PsiComment || element2 instanceof PsiComment)) {
|
||||
if (!(element1 instanceof PsiComment)) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
break;
|
||||
|
||||
+39
-11
@@ -37,9 +37,11 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.patterns.PsiJavaPatterns.psiClass;
|
||||
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
|
||||
@@ -117,26 +119,52 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
|
||||
final boolean pkgContext = JavaCompletionUtil.inSomePackage(insertedElement);
|
||||
AllClassesGetter.processJavaClasses(parameters, matcher, filterByScope, new Consumer<PsiClass>() {
|
||||
@Override
|
||||
public void consume(PsiClass psiClass) {
|
||||
if (filter.isAcceptable(psiClass, insertedElement)) {
|
||||
if (!inJavaContext) {
|
||||
consumer.consume(AllClassesGetter.createLookupItem(psiClass, AllClassesGetter.TRY_SHORTENING));
|
||||
} else {
|
||||
for (JavaPsiClassReferenceElement element : createClassLookupItems(psiClass, afterNew,
|
||||
JavaClassNameInsertHandler.JAVA_CLASS_INSERT_HANDLER, new Condition<PsiClass>() {
|
||||
@Override
|
||||
public void consume(PsiClass psiClass) {
|
||||
processClass(psiClass, ContainerUtil.<PsiClass>newHashSet(), "");
|
||||
}
|
||||
|
||||
private void processClass(PsiClass psiClass, Set<PsiClass> visited, String prefix) {
|
||||
if (!visited.add(psiClass)) return;
|
||||
|
||||
boolean isInnerClass = StringUtil.isNotEmpty(prefix);
|
||||
if (isInnerClass && isProcessedIndependently(psiClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (filter.isAcceptable(psiClass, insertedElement)) {
|
||||
if (!inJavaContext) {
|
||||
JavaPsiClassReferenceElement element = AllClassesGetter.createLookupItem(psiClass, AllClassesGetter.TRY_SHORTENING);
|
||||
element.setLookupString(prefix + element.getLookupString());
|
||||
consumer.consume(element);
|
||||
} else {
|
||||
for (JavaPsiClassReferenceElement element : createClassLookupItems(psiClass, afterNew,
|
||||
JavaClassNameInsertHandler.JAVA_CLASS_INSERT_HANDLER, new Condition<PsiClass>() {
|
||||
@Override
|
||||
public boolean value(PsiClass psiClass) {
|
||||
return filter.isAcceptable(psiClass, insertedElement) &&
|
||||
AllClassesGetter.isAcceptableInContext(insertedElement, psiClass, filterByScope, pkgContext);
|
||||
}
|
||||
})) {
|
||||
consumer.consume(element);
|
||||
}
|
||||
element.setLookupString(prefix + element.getLookupString());
|
||||
consumer.consume(element);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String name = psiClass.getName();
|
||||
if (name != null) {
|
||||
for (PsiClass innerClass : psiClass.getInnerClasses()) {
|
||||
processClass(innerClass, visited, prefix + name + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isProcessedIndependently(PsiClass psiClass) {
|
||||
String innerName = psiClass.getName();
|
||||
return innerName != null && matcher.prefixMatches(innerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static LookupElement highlightIfNeeded(JavaPsiClassReferenceElement element, CompletionParameters parameters) {
|
||||
|
||||
@@ -664,7 +664,20 @@ public class GenerateMembersUtil {
|
||||
}
|
||||
}
|
||||
result = (PsiMethod)CodeStyleManager.getInstance(project).reformat(result);
|
||||
PropertyUtil.annotateWithNullableStuff(field, result);
|
||||
|
||||
PsiModifierListOwner listOwner = null;
|
||||
if (templatesManager instanceof GetterTemplatesManager) {
|
||||
listOwner = result;
|
||||
}
|
||||
else {
|
||||
final PsiParameter[] parameters = result.getParameterList().getParameters();
|
||||
if (parameters.length == 1) {
|
||||
listOwner = parameters[0];
|
||||
}
|
||||
}
|
||||
if (listOwner != null) {
|
||||
PropertyUtil.annotateWithNullableStuff(field, listOwner);
|
||||
}
|
||||
return generatePrototype(field, result);
|
||||
}
|
||||
|
||||
|
||||
+22
-7
@@ -1,19 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.impl.source.resolve.reference.impl.providers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.PackageReferenceSet;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PatternPackageReferenceSet extends PackageReferenceSet {
|
||||
|
||||
public PatternPackageReferenceSet(String packageName, PsiElement element, int startInElement) {
|
||||
super(packageName, element, startInElement);
|
||||
}
|
||||
@@ -24,7 +39,7 @@ public class PatternPackageReferenceSet extends PackageReferenceSet {
|
||||
|
||||
if (packageName.contains("*")) {
|
||||
final Pattern pattern = PatternUtil.fromMask(packageName);
|
||||
final Set<PsiPackage> packages = new HashSet<PsiPackage>();
|
||||
final Set<PsiPackage> packages = new LinkedHashSet<PsiPackage>();
|
||||
|
||||
processSubPackages(context, new Processor<PsiPackage>() {
|
||||
@Override
|
||||
@@ -39,13 +54,13 @@ public class PatternPackageReferenceSet extends PackageReferenceSet {
|
||||
|
||||
return packages;
|
||||
}
|
||||
else {
|
||||
return super.resolvePackageName(context, packageName);
|
||||
}
|
||||
|
||||
return super.resolvePackageName(context, packageName);
|
||||
}
|
||||
|
||||
protected static boolean processSubPackages(final PsiPackage pkg, final Processor<PsiPackage> processor) {
|
||||
protected static boolean processSubPackages(final PsiPackage pkg, final Processor<PsiPackage> processor) {
|
||||
if (!processor.process(pkg)) return false;
|
||||
|
||||
for (final PsiPackage aPackage : pkg.getSubPackages()) {
|
||||
if (!processSubPackages(aPackage, processor)) return false;
|
||||
}
|
||||
|
||||
@@ -17,60 +17,40 @@ package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
*/
|
||||
public class PsiMethodReferenceUtil {
|
||||
public static final Logger LOG = Logger.getInstance("#" + PsiMethodReferenceUtil.class.getName());
|
||||
|
||||
public static boolean hasReceiver(PsiType[] parameterTypes, QualifierResolveResult qualifierResolveResult, PsiMethodReferenceExpression methodRef) {
|
||||
if (parameterTypes.length > 0 &&
|
||||
public static boolean isSecondSearchPossible(PsiType[] parameterTypes,
|
||||
QualifierResolveResult qualifierResolveResult,
|
||||
PsiMethodReferenceExpression methodRef) {
|
||||
if (parameterTypes.length > 0 &&
|
||||
!methodRef.isConstructor() &&
|
||||
isReceiverType(parameterTypes[0], qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor()) &&
|
||||
isStaticallyReferenced(methodRef)) {
|
||||
isStaticallyReferenced(methodRef) &&
|
||||
isReceiverType(parameterTypes[0], qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String checkReturnType(PsiMethodReferenceExpression expression, JavaResolveResult result, PsiType functionalInterfaceType) {
|
||||
final PsiElement resolve = result.getElement();
|
||||
if (resolve instanceof PsiMethod) {
|
||||
final PsiClass containingClass = ((PsiMethod)resolve).getContainingClass();
|
||||
LOG.assertTrue(containingClass != null);
|
||||
PsiSubstitutor subst = result.getSubstitutor();
|
||||
PsiClass qContainingClass = getQualifierResolveResult(expression).getContainingClass();
|
||||
if (qContainingClass != null && isReceiverType(functionalInterfaceType, containingClass, (PsiMethod)resolve)) {
|
||||
subst = TypeConversionUtil.getClassSubstitutor(containingClass, qContainingClass, subst);
|
||||
LOG.assertTrue(subst != null);
|
||||
}
|
||||
|
||||
|
||||
final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType);
|
||||
|
||||
PsiType returnType = PsiTypesUtil.patchMethodGetClassReturnType(expression, expression,
|
||||
(PsiMethod)resolve, null,
|
||||
PsiUtil.getLanguageLevel(expression));
|
||||
if (returnType == null) {
|
||||
returnType = ((PsiMethod)resolve).getReturnType();
|
||||
}
|
||||
PsiType methodReturnType = subst.substitute(returnType);
|
||||
if (interfaceReturnType != null && interfaceReturnType != PsiType.VOID) {
|
||||
if (methodReturnType == null) {
|
||||
methodReturnType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(containingClass, subst);
|
||||
}
|
||||
if (!TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType, false)) {
|
||||
return "Bad return type in method reference: cannot convert " + methodReturnType.getCanonicalText() + " to " + interfaceReturnType.getCanonicalText();
|
||||
}
|
||||
}
|
||||
public static boolean isResolvedBySecondSearch(@NotNull PsiMethodReferenceExpression methodRef,
|
||||
@Nullable MethodSignature signature,
|
||||
boolean varArgs,
|
||||
boolean isStatic,
|
||||
int parametersCount) {
|
||||
if (signature == null) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
final QualifierResolveResult qualifierResolveResult = getQualifierResolveResult(methodRef);
|
||||
final PsiType[] functionalMethodParameterTypes = signature.getParameterTypes();
|
||||
return (parametersCount + 1 == functionalMethodParameterTypes.length && !varArgs ||
|
||||
varArgs && functionalMethodParameterTypes.length > 0 && !isStatic) &&
|
||||
isSecondSearchPossible(functionalMethodParameterTypes, qualifierResolveResult, methodRef);
|
||||
}
|
||||
|
||||
public static boolean isCorrectAssignment(PsiType[] parameterTypes,
|
||||
@@ -163,7 +143,7 @@ public class PsiMethodReferenceUtil {
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
final PsiExpression expression = methodReferenceExpression.getQualifierExpression();
|
||||
if (expression != null) {
|
||||
final PsiType expressionType = getExpandedType(expression.getType(), expression);
|
||||
final PsiType expressionType = replaceArrayType(expression.getType(), expression);
|
||||
PsiClassType.ClassResolveResult result = PsiUtil.resolveGenericsClassInType(expressionType);
|
||||
containingClass = result.getElement();
|
||||
if (containingClass != null) {
|
||||
@@ -182,7 +162,7 @@ public class PsiMethodReferenceUtil {
|
||||
else {
|
||||
final PsiTypeElement typeElement = methodReferenceExpression.getQualifierType();
|
||||
if (typeElement != null) {
|
||||
PsiType type = getExpandedType(typeElement.getType(), typeElement);
|
||||
PsiType type = replaceArrayType(typeElement.getType(), typeElement);
|
||||
PsiClassType.ClassResolveResult result = PsiUtil.resolveGenericsClassInType(type);
|
||||
containingClass = result.getElement();
|
||||
if (containingClass != null) {
|
||||
@@ -202,59 +182,33 @@ public class PsiMethodReferenceUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isReceiverType(@Nullable PsiClass aClass, @Nullable PsiClass containingClass) {
|
||||
return InheritanceUtil.isInheritorOrSelf(aClass, containingClass, true);
|
||||
}
|
||||
|
||||
public static boolean isReceiverType(PsiType receiverType, @Nullable PsiClass containingClass, PsiSubstitutor psiSubstitutor) {
|
||||
if (containingClass != null) {
|
||||
receiverType = getExpandedType(receiverType, containingClass);
|
||||
//if P1, ..., Pn is not empty and P1 is a subtype of ReferenceType, then the method reference expression is treated as
|
||||
// if it were a method invocation expression with argument expressions of types P2, ...,Pn.
|
||||
public static boolean isReceiverType(@Nullable PsiType receiverType, PsiClass containingClass, PsiSubstitutor psiSubstitutor) {
|
||||
if (receiverType == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(receiverType);
|
||||
final PsiClass receiverClass = resolveResult.getElement();
|
||||
if (receiverClass != null && isReceiverType(receiverClass, containingClass)) {
|
||||
if (emptyOrRaw(containingClass, psiSubstitutor)) {
|
||||
return true;
|
||||
}
|
||||
final PsiSubstitutor derivedSubstitutor = TypeConversionUtil.getClassSubstitutor(containingClass, receiverClass, psiSubstitutor);
|
||||
return derivedSubstitutor != null && TypeConversionUtil.isAssignable(JavaPsiFacade.getElementFactory(containingClass.getProject()).createType(containingClass, derivedSubstitutor), receiverType);
|
||||
}
|
||||
return false;
|
||||
return TypeConversionUtil.isAssignable(JavaPsiFacade.getElementFactory(containingClass.getProject()).createType(containingClass, psiSubstitutor),
|
||||
replaceArrayType(receiverType, containingClass));
|
||||
}
|
||||
|
||||
private static boolean emptyOrRaw(PsiClass containingClass, PsiSubstitutor psiSubstitutor) {
|
||||
return PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor) ||
|
||||
psiSubstitutor.getSubstitutionMap().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isReceiverType(PsiType functionalInterfaceType, PsiClass containingClass, @Nullable PsiMethod referencedMethod) {
|
||||
public static PsiType getFirstParameterType(PsiType functionalInterfaceType, PsiElement context) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
final MethodSignature function = LambdaUtil.getFunction(resolveResult.getElement());
|
||||
if (function != null) {
|
||||
final int interfaceMethodParamsLength = function.getParameterTypes().length;
|
||||
if (interfaceMethodParamsLength > 0) {
|
||||
final PsiType firstParamType = resolveResult.getSubstitutor().substitute(function.getParameterTypes()[0]);
|
||||
boolean isReceiver = isReceiverType(firstParamType,
|
||||
containingClass, PsiUtil.resolveGenericsClassInType(firstParamType).getSubstitutor());
|
||||
if (isReceiver) {
|
||||
if (referencedMethod == null){
|
||||
if (interfaceMethodParamsLength == 1) return true;
|
||||
return false;
|
||||
}
|
||||
if (referencedMethod.getParameterList().getParametersCount() != interfaceMethodParamsLength - 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
PsiType type = resolveResult.getSubstitutor().substitute(function.getParameterTypes()[0]);
|
||||
return type != null ? PsiUtil.captureToplevelWildcards(type, context) : null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PsiType getExpandedType(PsiType type, @NotNull PsiElement typeElement) {
|
||||
private static PsiType replaceArrayType(PsiType type, @NotNull PsiElement context) {
|
||||
if (type instanceof PsiArrayType) {
|
||||
type = JavaPsiFacade.getElementFactory(typeElement.getProject())
|
||||
.getArrayClassType(((PsiArrayType)type).getComponentType(), PsiUtil.getLanguageLevel(typeElement));
|
||||
type = JavaPsiFacade.getElementFactory(context.getProject())
|
||||
.getArrayClassType(((PsiArrayType)type).getComponentType(), PsiUtil.getLanguageLevel(context));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -282,8 +236,15 @@ public class PsiMethodReferenceUtil {
|
||||
|
||||
isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC);
|
||||
isConstructor = method.isConstructor();
|
||||
receiverReferenced = hasReceiver(methodRef, method, functionalInterfaceType);
|
||||
|
||||
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
|
||||
receiverReferenced = isResolvedBySecondSearch(methodRef,
|
||||
interfaceMethod != null ? interfaceMethod.getSignature(LambdaUtil.getSubstitutor(interfaceMethod, resolveResult)) : null,
|
||||
method.isVarArgs(),
|
||||
isMethodStatic,
|
||||
method.getParameterList().getParametersCount());
|
||||
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) && qualifier instanceof PsiSuperExpression) {
|
||||
return "Abstract method '" + method.getName() + "' cannot be accessed directly";
|
||||
}
|
||||
@@ -322,27 +283,6 @@ public class PsiMethodReferenceUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasReceiver(@NotNull PsiMethodReferenceExpression methodRef,
|
||||
@NotNull PsiMethod method) {
|
||||
return hasReceiver(methodRef, method, methodRef.getFunctionalInterfaceType());
|
||||
}
|
||||
|
||||
private static boolean hasReceiver(@NotNull PsiMethodReferenceExpression methodRef,
|
||||
@NotNull PsiMethod method,
|
||||
PsiType functionalInterfaceType) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
|
||||
final MethodSignature signature = interfaceMethod != null ? interfaceMethod.getSignature(LambdaUtil.getSubstitutor(interfaceMethod, resolveResult)) : null;
|
||||
if (signature == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType[] parameterTypes = signature.getParameterTypes();
|
||||
final QualifierResolveResult qualifierResolveResult = getQualifierResolveResult(methodRef);
|
||||
return (method.getParameterList().getParametersCount() + 1 == parameterTypes.length ||
|
||||
method.isVarArgs() && parameterTypes.length > 0 && !method.hasModifierProperty(PsiModifier.STATIC)) &&
|
||||
hasReceiver(parameterTypes, qualifierResolveResult, methodRef);
|
||||
}
|
||||
|
||||
public static String checkTypeArguments(PsiTypeElement qualifier, PsiType psiType) {
|
||||
if (psiType instanceof PsiClassType) {
|
||||
final PsiJavaCodeReferenceElement referenceElement = qualifier.getInnermostComponentReferenceElement();
|
||||
@@ -357,4 +297,38 @@ public class PsiMethodReferenceUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String checkReturnType(PsiMethodReferenceExpression expression, JavaResolveResult result, PsiType functionalInterfaceType) {
|
||||
final PsiElement resolve = result.getElement();
|
||||
if (resolve instanceof PsiMethod) {
|
||||
final PsiClass containingClass = ((PsiMethod)resolve).getContainingClass();
|
||||
LOG.assertTrue(containingClass != null);
|
||||
PsiSubstitutor subst = result.getSubstitutor();
|
||||
PsiClass qContainingClass = getQualifierResolveResult(expression).getContainingClass();
|
||||
if (qContainingClass != null && isReceiverType(getFirstParameterType(functionalInterfaceType, expression), qContainingClass, subst)) {
|
||||
subst = TypeConversionUtil.getClassSubstitutor(containingClass, qContainingClass, subst);
|
||||
LOG.assertTrue(subst != null);
|
||||
}
|
||||
|
||||
|
||||
final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType);
|
||||
|
||||
PsiType returnType = PsiTypesUtil.patchMethodGetClassReturnType(expression, expression,
|
||||
(PsiMethod)resolve, null,
|
||||
PsiUtil.getLanguageLevel(expression));
|
||||
if (returnType == null) {
|
||||
returnType = ((PsiMethod)resolve).getReturnType();
|
||||
}
|
||||
PsiType methodReturnType = subst.substitute(returnType);
|
||||
if (interfaceReturnType != null && interfaceReturnType != PsiType.VOID) {
|
||||
if (methodReturnType == null) {
|
||||
methodReturnType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(containingClass, subst);
|
||||
}
|
||||
if (!TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType, false)) {
|
||||
return "Bad return type in method reference: cannot convert " + methodReturnType.getCanonicalText() + " to " + interfaceReturnType.getCanonicalText();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,48 +116,36 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return getApplicabilityLevel();
|
||||
}
|
||||
@ApplicabilityLevelConstant int level;
|
||||
Integer boxedLevel = ourOverloadGuard.doPreventingRecursion(myArgumentList, false, new Computable<Integer>() {
|
||||
@Override
|
||||
public Integer compute() {
|
||||
if (PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
|
||||
PsiSubstitutor substitutor = getSubstitutor(false);
|
||||
Map<PsiElement, CurrentCandidateProperties> map = CURRENT_CANDIDATE.get();
|
||||
if (map == null) {
|
||||
map = ContainerUtil.createConcurrentWeakMap();
|
||||
CURRENT_CANDIDATE.set(map);
|
||||
}
|
||||
final PsiMethod method = getElement();
|
||||
final CurrentCandidateProperties properties = new CurrentCandidateProperties(method, substitutor, isVarargs(), true);
|
||||
final CurrentCandidateProperties alreadyThere = map.put(getMarkerList(), properties);
|
||||
try {
|
||||
PsiType[] argumentTypes = getArgumentTypes();
|
||||
if (argumentTypes == null) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
|
||||
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method, substitutor, argumentTypes, myLanguageLevel);
|
||||
if (!isVarargs() && applicabilityLevel < ApplicabilityLevel.FIXED_ARITY) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
return applicabilityLevel;
|
||||
}
|
||||
finally {
|
||||
if (alreadyThere == null) {
|
||||
map.remove(getMarkerList());
|
||||
} else {
|
||||
map.put(getMarkerList(), alreadyThere);
|
||||
}
|
||||
}
|
||||
}
|
||||
return getApplicabilityLevelInner();
|
||||
PsiSubstitutor substitutor = getSubstitutor(false);
|
||||
Map<PsiElement, CurrentCandidateProperties> map = CURRENT_CANDIDATE.get();
|
||||
if (map == null) {
|
||||
map = ContainerUtil.createConcurrentWeakMap();
|
||||
CURRENT_CANDIDATE.set(map);
|
||||
}
|
||||
final PsiMethod method = getElement();
|
||||
final CurrentCandidateProperties properties = new CurrentCandidateProperties(method, substitutor, isVarargs(), true);
|
||||
final CurrentCandidateProperties alreadyThere = map.put(getMarkerList(), properties);
|
||||
try {
|
||||
PsiType[] argumentTypes = getArgumentTypes();
|
||||
if (argumentTypes == null) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
|
||||
});
|
||||
if (boxedLevel == null) {
|
||||
return getApplicabilityLevel();
|
||||
level = PsiUtil.getApplicabilityLevel(method, substitutor, argumentTypes, myLanguageLevel);
|
||||
if (!isVarargs() && level < ApplicabilityLevel.FIXED_ARITY) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (alreadyThere == null) {
|
||||
map.remove(getMarkerList());
|
||||
} else {
|
||||
map.put(getMarkerList(), alreadyThere);
|
||||
}
|
||||
}
|
||||
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(false)) {
|
||||
level = ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
level = boxedLevel;
|
||||
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(false)) level = ApplicabilityLevel.NOT_APPLICABLE;
|
||||
return level;
|
||||
}
|
||||
|
||||
@@ -312,17 +300,17 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
|
||||
|
||||
public static CurrentCandidateProperties getCurrentMethod(PsiElement context) {
|
||||
if (isOverloadCheck()) {
|
||||
ourOverloadGuard.prohibitResultCaching(ourOverloadGuard.currentStack().get(0));
|
||||
}
|
||||
final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
|
||||
return currentMethodCandidates != null ? currentMethodCandidates.get(context) : null;
|
||||
}
|
||||
|
||||
public static void updateSubstitutor(PsiElement context, PsiSubstitutor newSubstitutor) {
|
||||
final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
|
||||
if (currentMethodCandidates != null) {
|
||||
final CurrentCandidateProperties properties = currentMethodCandidates.get(context);
|
||||
if (properties != null) {
|
||||
properties.setSubstitutor(newSubstitutor);
|
||||
}
|
||||
CurrentCandidateProperties candidateProperties = getCurrentMethod(context);
|
||||
if (candidateProperties != null) {
|
||||
candidateProperties.setSubstitutor(newSubstitutor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -396,8 +396,17 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
return parent instanceof PsiNewExpression ? ((PsiNewExpression)parent).getArgumentList() : super.getMarkerList();
|
||||
}
|
||||
};
|
||||
if (!varargs && staticFactoryMethod.isVarArgs() && staticFactoryCandidateInfo.getPertinentApplicabilityLevel() < MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
|
||||
return inferTypeParametersForStaticFactory(staticFactoryMethod, expression, parent, true);
|
||||
if (!varargs && staticFactoryMethod.isVarArgs()) {
|
||||
final Computable<Integer> computable = new Computable<Integer>() {
|
||||
@Override
|
||||
public Integer compute() {
|
||||
return staticFactoryCandidateInfo.getPertinentApplicabilityLevel();
|
||||
}
|
||||
};
|
||||
final Integer applicability = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(expression, true, computable);
|
||||
if ((applicability != null ? applicability : staticFactoryCandidateInfo.getApplicabilityLevel()) < MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
|
||||
return inferTypeParametersForStaticFactory(staticFactoryMethod, expression, parent, true);
|
||||
}
|
||||
}
|
||||
return staticFactoryCandidateInfo.getSubstitutor();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -711,6 +712,10 @@ public class PsiClassImplUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiClassType correctType(PsiClassType originalType, final GlobalSearchScope resolveScope) {
|
||||
if (!Registry.is("java.correct.class.type.by.place.resolve.scope")) {
|
||||
return originalType;
|
||||
}
|
||||
|
||||
final PsiClassType.ClassResolveResult originalResolveResult = originalType.resolveGenerics();
|
||||
PsiClass superClass = originalResolveResult.getElement();
|
||||
if (superClass == null) {
|
||||
@@ -746,7 +751,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
});
|
||||
if (substitute == null) return null;
|
||||
|
||||
|
||||
substitutor = substitutor.put(typeParameters[i], substitute);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1223,8 +1223,7 @@ public class InferenceSession {
|
||||
PsiImplUtil.normalizeWildcardTypeByPosition(pType, reference)));
|
||||
}
|
||||
}
|
||||
else if (parameters.length + 1 == functionalMethodParameters.length && !varargs ||
|
||||
!isStatic && varargs && functionalMethodParameters.length > 0 && PsiMethodReferenceUtil.hasReceiver(reference, method)) { //instance methods
|
||||
else if (PsiMethodReferenceUtil.isResolvedBySecondSearch(reference, signature, varargs, isStatic, parameters.length)) { //instance methods
|
||||
initBounds(containingClass.getTypeParameters());
|
||||
|
||||
final PsiType pType = signature.getParameterTypes()[0];
|
||||
|
||||
+10
-3
@@ -18,10 +18,12 @@ package com.intellij.psi.impl.source.resolve.graphInference.constraints;
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Function;
|
||||
@@ -45,7 +47,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reduce(InferenceSession session, List<ConstraintFormula> constraints) {
|
||||
public boolean reduce(final InferenceSession session, List<ConstraintFormula> constraints) {
|
||||
if (!PsiPolyExpressionUtil.isPolyExpression(myExpression)) {
|
||||
return true;
|
||||
}
|
||||
@@ -111,7 +113,12 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
}
|
||||
});
|
||||
if (exceptions != null) {
|
||||
thrownTypes.addAll(exceptions);
|
||||
thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition<PsiClassType>() {
|
||||
@Override
|
||||
public boolean value(PsiClassType type) {
|
||||
return session.isProperType(type) && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_EXCEPTION);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -169,7 +176,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
|
||||
private static boolean isAddressed(List<PsiType> expectedThrownTypes, PsiType thrownType) {
|
||||
for (PsiType expectedThrownType : expectedThrownTypes) {
|
||||
if (TypeConversionUtil.isAssignable(expectedThrownType, thrownType)) {
|
||||
if (TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(thrownType), expectedThrownType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -16,10 +16,10 @@
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.infos.ClassCandidateInfo;
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MethodReferenceResolver implements ResolveCache.PolyVariantContextResolver<PsiMethodReferenceExpressionImpl> {
|
||||
private static final Logger LOG = Logger.getInstance("#" + MethodReferenceResolver.class.getName());
|
||||
@@ -214,14 +213,14 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts) {
|
||||
protected CandidateInfo guardedOverloadResolution(@NotNull List<CandidateInfo> conflicts) {
|
||||
if (mySignature == null) return null;
|
||||
|
||||
if (conflicts.size() > 1) checkSameSignatures(conflicts);
|
||||
if (conflicts.size() > 1) checkAccessStaticLevels(conflicts, true);
|
||||
|
||||
final PsiType[] argTypes = mySignature.getParameterTypes();
|
||||
boolean hasReceiver = PsiMethodReferenceUtil.hasReceiver(argTypes, myQualifierResolveResult, myReferenceExpression);
|
||||
boolean hasReceiver = PsiMethodReferenceUtil.isSecondSearchPossible(argTypes, myQualifierResolveResult, myReferenceExpression);
|
||||
|
||||
final List<CandidateInfo> firstCandidates = new ArrayList<CandidateInfo>();
|
||||
final List<CandidateInfo> secondCandidates = new ArrayList<CandidateInfo>();
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
|
||||
@@ -480,7 +479,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
|
||||
PsiClass qContainingClass = PsiMethodReferenceUtil.getQualifierResolveResult(this).getContainingClass();
|
||||
if (qContainingClass != null && containingClass != null &&
|
||||
PsiMethodReferenceUtil.isReceiverType(left, containingClass, (PsiMethod)resolve)) {
|
||||
PsiMethodReferenceUtil.isReceiverType(PsiMethodReferenceUtil.getFirstParameterType(left, this), qContainingClass, subst)) {
|
||||
subst = TypeConversionUtil.getClassSubstitutor(containingClass, qContainingClass, subst);
|
||||
LOG.assertTrue(subst != null);
|
||||
}
|
||||
|
||||
+12
-1
@@ -20,6 +20,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
|
||||
@@ -68,7 +69,17 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
|
||||
@Override
|
||||
public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts){
|
||||
public final CandidateInfo resolveConflict(@NotNull final List<CandidateInfo> conflicts){
|
||||
return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, true, new Computable<CandidateInfo>() {
|
||||
@Override
|
||||
public CandidateInfo compute() {
|
||||
return guardedOverloadResolution(conflicts);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected CandidateInfo guardedOverloadResolution(@NotNull List<CandidateInfo> conflicts) {
|
||||
if (conflicts.isEmpty()) return null;
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
final class MyModule {
|
||||
@Target({FIELD,PARAMETER,METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public static @interface Dependency { }
|
||||
}
|
||||
|
||||
final class SomeService {
|
||||
|
||||
SomeService(@My<caret>) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
final class MyModule {
|
||||
@Target({FIELD,PARAMETER,METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public static @interface Dependency { }
|
||||
}
|
||||
|
||||
final class SomeService {
|
||||
|
||||
SomeService(@MyModule.Dependency<caret>) {
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
|
||||
interface B<K, E extends Throwable> {
|
||||
K l(K k) throws E;
|
||||
}
|
||||
|
||||
<R> void bar(B<R, IOException> b) {}
|
||||
|
||||
<E extends Exception, T> T baz(T l) throws E {
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
bar(l -> baz(l));
|
||||
bar(this::baz);
|
||||
}
|
||||
}
|
||||
class Test1 {
|
||||
|
||||
interface B<K, E extends Throwable> {
|
||||
K l(K k) throws E;
|
||||
}
|
||||
|
||||
<R> void bar(B<R, IOException> b) {}
|
||||
|
||||
class MyEx extends Exception{}
|
||||
|
||||
<E extends MyEx, T> T baz(T l) throws E {
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
bar(l -> baz<error descr="'baz(java.lang.Object)' in 'Test1' cannot be applied to '(<lambda parameter>)'">(l)</error>);
|
||||
bar(<error descr="Unhandled exception: Test1.MyEx">this::baz</error>);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
|
||||
public Long getKey() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static void main(Stream<Test> stream) {
|
||||
stream.map(s -> Inner.of(Test::getKey, s));
|
||||
}
|
||||
|
||||
public static final class Inner<K> {
|
||||
public static <T> Inner<T> of(final Object key, final Test value) {return null;}
|
||||
public static <T> Inner<T> of(final Function< T, Long> keyMapper, final Test value) {return null;}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
|
||||
static class Base {
|
||||
public BigDecimal getTotal() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void foo(List<? extends Base> list, List<Base> list1) {
|
||||
System.out.println(add(list, Base::getTotal));
|
||||
list1.forEach(Base::getTotal);
|
||||
}
|
||||
|
||||
|
||||
public static <T> BigDecimal add(Collection<T> objectsThatHaveBigDecimals, Function<T, ? extends BigDecimal> functionToGet) {
|
||||
return objectsThatHaveBigDecimals == null ? null : objectsThatHaveBigDecimals.stream().map(functionToGet).reduce(null, Test::add);
|
||||
}
|
||||
|
||||
public static BigDecimal add(BigDecimal... sequence) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collector;
|
||||
|
||||
class Test {
|
||||
public static final <T> Collector<T, AtomicReference<T>, Optional<T>> toSingleton() {
|
||||
return Collector.of(
|
||||
AtomicReference::new,
|
||||
(ref, v) -> {
|
||||
if (!ref.compareAndSet(null, v) && v != null) {
|
||||
throw new IllegalStateException("There is only one elvis.");
|
||||
}
|
||||
},
|
||||
(left, right) -> setOrFail(left, right.get()),
|
||||
ref -> Optional.of(ref.get())
|
||||
);
|
||||
}
|
||||
|
||||
public static final <T> Collector<T, AtomicReference<T>, Optional<T>> toSingleton1() {
|
||||
return Collector.of(
|
||||
AtomicReference::new,
|
||||
(ref, v) -> setOrFail(ref, v),
|
||||
(left, right) -> setOrFail(left, right.get()),
|
||||
ref -> Optional.of(ref.get())
|
||||
);
|
||||
}
|
||||
|
||||
public static final <T> Collector<T, AtomicReference<T>, Optional<T>> toSingleton2() {
|
||||
return Collector.of(
|
||||
AtomicReference::new,
|
||||
Test::setOrFail,
|
||||
(left, right) -> setOrFail(left, right.get()),
|
||||
ref -> Optional.of(ref.get())
|
||||
);
|
||||
}
|
||||
|
||||
private static final <T> AtomicReference<T> setOrFail(AtomicReference<T> ref, T v) {
|
||||
if (!ref.compareAndSet(null, v) && v != null) {
|
||||
throw new IllegalStateException("There is only one elvis.");
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.Collection;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
public static <T> int sum(Collection<? extends T> collection, ToIntFunction<? super T> mapper) {
|
||||
return collection.stream().collect(Collectors.summingInt(mapper));
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
|
||||
public Long getKey() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static void main(Stream<Test> stream) {
|
||||
stream.map(s -> Inner.of(Test::get<ref>Key, s));
|
||||
}
|
||||
|
||||
public static final class Inner<K> {
|
||||
public static <T> Inner<T> of(final Object key, final Test value) {return null;}
|
||||
public static <T> Inner<T> of(final Function< T, Long> keyMapper, final Test value) {return null;}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.counting;
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
|
||||
abstract class Token {
|
||||
|
||||
|
||||
private static B<Long> getMode(Optional<Map.Entry<Integer, Long>> max){
|
||||
return max
|
||||
.flatMap(e -> Optional.of(new B<>(Long.valu<ref>eOf(e.getValue().longValue()))))
|
||||
.get();
|
||||
}
|
||||
|
||||
static class B<K> {
|
||||
public B(K k) {}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,38 @@ class Foo {
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test nullable stuff"() {
|
||||
myFixture.addClass("package org.jetbrains.annotations;\n" +
|
||||
"public @interface NotNull {}")
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class Foo {
|
||||
@org.jetbrains.annotations.NotNull
|
||||
private String myName;
|
||||
|
||||
<caret>
|
||||
}
|
||||
'''
|
||||
generateGetter()
|
||||
generateSetter()
|
||||
myFixture.checkResult '''import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Foo {
|
||||
@org.jetbrains.annotations.NotNull
|
||||
private String myName;
|
||||
|
||||
public void setMyName(@NotNull String myName) {
|
||||
this.myName = myName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMyName() {
|
||||
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
private void generateGetter() {
|
||||
WriteCommandAction.runWriteCommandAction(getProject(), {
|
||||
new GenerateGetterHandler() {
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
*/
|
||||
class MultipleModuleHighlightingTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
@Bombed(day = 1, month = Calendar.MARCH)
|
||||
@Bombed(day = 1, month = Calendar.APRIL)
|
||||
public void "test use original place classpath for reference type resolving"() {
|
||||
addTwoModules()
|
||||
|
||||
@@ -60,7 +60,7 @@ class Class3 {
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
|
||||
@Bombed(day = 1, month = Calendar.MARCH)
|
||||
@Bombed(day = 1, month = Calendar.APRIL)
|
||||
public void "test use original place classpath for new expression type resolving"() {
|
||||
addTwoModules()
|
||||
|
||||
|
||||
+1
@@ -932,6 +932,7 @@ public class ListUtils {
|
||||
|
||||
public void testTabReplacesMethodNameWithLocalVariableName() throws Throwable { doTest('\t'); }
|
||||
public void testMethodParameterAnnotationClass() throws Throwable { doTest(); }
|
||||
public void testInnerAnnotation() { doTest('\n'); }
|
||||
public void testPrimitiveCastOverwrite() throws Throwable { doTest '\t' }
|
||||
public void testClassReferenceInFor() throws Throwable { doTest ' ' }
|
||||
public void testClassReferenceInFor2() throws Throwable { doTest ' ' }
|
||||
|
||||
-2
@@ -16,7 +16,6 @@
|
||||
package com.intellij.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
@@ -25,7 +24,6 @@ import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class Java8RegressionTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/regression";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
enableInspectionTool(new UnusedDeclarationInspection());
|
||||
}
|
||||
|
||||
public void testIDEA136856() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA136887() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(boolean warnings) {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
+11
-7
@@ -17,14 +17,13 @@ package com.intellij.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newLambda";
|
||||
|
||||
@@ -80,7 +79,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testLiftedIntersectionType() { doTest(); }
|
||||
public void testInferenceFromReturnStatements() { doTest(); }
|
||||
public void testDownUpThroughLambdaReturnStatements() { doTest(); }
|
||||
@Bombed(year = 2015, month = Calendar.MARCH, day = 30)
|
||||
public void testIDEA124547() { doTest(); }
|
||||
public void testIDEA118362() { doTest(); }
|
||||
public void testIDEA126056() { doTest(); }
|
||||
@@ -139,11 +137,14 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Bombed(year = 2015, month = Calendar.MARCH, day = 30)
|
||||
public void testCheckedExceptionsConstraintsSubstitutions() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckedExceptionsConstraintsSubstitutions1() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckedExceptionsConstraintsSubstitutionsDeepInBody() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
@@ -168,7 +169,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Bombed(year = 2015, month = Calendar.MARCH, day = 30)
|
||||
public void testIDEA127124() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
@@ -177,6 +177,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA136759() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
@@ -193,7 +197,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
/*
|
||||
public static Test suite() {
|
||||
final TestSuite suite = new TestSuite();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
suite.addTestSuite(NewLambdaHighlightingTest.class);
|
||||
}
|
||||
return suite;
|
||||
|
||||
+4
-4
@@ -19,15 +19,12 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef";
|
||||
|
||||
@@ -373,7 +370,6 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Bombed(year = 2015, month = Calendar.MARCH, day = 30)
|
||||
public void testIDEA132379() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
@@ -386,6 +382,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testSecondSearchIfFirstParameterIsASubtypeOfReferenceTypeFromExpressionDeclaration() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+21
@@ -21,6 +21,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.ResolveTestCase;
|
||||
|
||||
@@ -30,6 +31,18 @@ public class TypeInference18Test extends ResolveTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSecondConflictResolution() throws Exception {
|
||||
doTestMethodCall();
|
||||
}
|
||||
|
||||
public void testCachedSubstitutionDuringOverloadResolution() throws Exception {
|
||||
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
|
||||
assertNotNull(ref);
|
||||
PsiMethodReferenceExpression methodCallExpression = PsiTreeUtil.getParentOfType(ref.getElement(), PsiMethodReferenceExpression.class, false);
|
||||
assertNotNull(methodCallExpression);
|
||||
assertNotNull(methodCallExpression.resolve());
|
||||
}
|
||||
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
|
||||
@Override
|
||||
@@ -46,6 +59,14 @@ public class TypeInference18Test extends ResolveTestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private void doTestMethodCall() throws Exception {
|
||||
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
|
||||
assertNotNull(ref);
|
||||
PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(ref.getElement(), PsiMethodCallExpression.class);
|
||||
assertNotNull(methodCallExpression);
|
||||
assertNotNull(methodCallExpression.resolveMethod());
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
|
||||
assertNotNull(ref);
|
||||
|
||||
@@ -365,6 +365,19 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
assertSize(1, findUsages(findModel));
|
||||
}
|
||||
|
||||
public void testNonSourceContent() throws Exception {
|
||||
VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTempDirectory());
|
||||
PsiTestUtil.addContentRoot(myModule, root);
|
||||
|
||||
createFile(myModule, root, "A.txt", "goo doo");
|
||||
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("goo");
|
||||
findModel.setProjectScope(false);
|
||||
findModel.setModuleName(myModule.getName());
|
||||
|
||||
assertSize(1, findUsages(findModel));
|
||||
}
|
||||
|
||||
public void testReplaceRegexp() {
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("bug_(?=here)");
|
||||
@@ -537,6 +550,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
findModel.setCustomScope(true);
|
||||
|
||||
ThrowableRunnable test = new ThrowableRunnable() {
|
||||
@Override
|
||||
@@ -573,6 +587,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
VirtualFile file = tempDirFixture.createFile("a.txt", "foo bar foo");
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setCustomScope(true);
|
||||
findModel.setCustomScope(new LocalSearchScope(PsiManager.getInstance(myProject).findFile(file)));
|
||||
assertSize(2, findUsages(findModel));
|
||||
}
|
||||
|
||||
+10
-10
@@ -165,7 +165,7 @@ class JavaPredefinedConfigurations {
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.typed.symbol"),"'Symbol <'_GenericArgument+>", GENERICS_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.generic.casts"),"( '_Type <'_GenericArgument+> ) '_Expr", GENERICS_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.type.var.substitutions.in.intanceof.with.generic.types"),"'_Expr instanceof '_Type <'Substitutions+> ", GENERICS_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.variables.of.generic.types"),"'_Type <'_GenericArgument+> 'Var = 'Init?;", GENERICS_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.variables.of.generic.types"),"'_Type <'_GenericArgument+> 'Var = '_Init?;", GENERICS_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.diamond.operators"), "new 'ClassName<>('_Argument*)", GENERICS_TYPE),
|
||||
|
||||
// Add comments and metadata
|
||||
@@ -226,7 +226,7 @@ class JavaPredefinedConfigurations {
|
||||
" public void ejbRemove();\n" +
|
||||
"}", J2EE_TYPE),
|
||||
createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.ejb.interface"),"interface 'EjbInterface extends EJBObject {\n" +
|
||||
" 'Type+ 'Method+('ParamType* 'ParamName*);\n" +
|
||||
" '_Type+ '_Method+('_ParamType* '_ParamName*);\n" +
|
||||
"}", J2EE_TYPE),
|
||||
createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.servlets"),"public class 'Servlet extends '_ParentClass:*HttpServlet {\n" +
|
||||
" public void '_InitServletMethod?:init ();\n" +
|
||||
@@ -243,19 +243,19 @@ class JavaPredefinedConfigurations {
|
||||
|
||||
// Misc types
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.serializable.classes.and.their.serialization.implementation"),
|
||||
"class '_Class implements '_Serializable:*Serializable {\n" +
|
||||
" static final long 'VersionField?:serialVersionUID = '_VersionFieldInit?;\n" +
|
||||
"class 'Class implements '_Serializable:*Serializable {\n" +
|
||||
" static final long '_VersionField?:serialVersionUID = '_VersionFieldInit?;\n" +
|
||||
" private static final ObjectStreamField[] '_persistentFields?:serialPersistentFields = '_persistentFieldInitial?; \n" +
|
||||
" private void 'SerializationWriteHandler?:writeObject (ObjectOutputStream '_stream) throws IOException;\n" +
|
||||
" private void 'SerializationReadHandler?:readObject (ObjectInputStream '_stream2) throws IOException, ClassNotFoundException;\n" +
|
||||
" Object 'SpecialSerializationReadHandler?:readResolve () throws ObjectStreamException;\n" +
|
||||
" Object 'SpecialSerializationWriteHandler?:writeReplace () throws ObjectStreamException;\n" +
|
||||
" private void '_SerializationWriteHandler?:writeObject (ObjectOutputStream '_stream) throws IOException;\n" +
|
||||
" private void '_SerializationReadHandler?:readObject (ObjectInputStream '_stream2) throws IOException, ClassNotFoundException;\n" +
|
||||
" Object '_SpecialSerializationReadHandler?:readResolve () throws ObjectStreamException;\n" +
|
||||
" Object '_SpecialSerializationWriteHandler?:writeReplace () throws ObjectStreamException;\n" +
|
||||
"}",MISC_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.cloneable.implementations"),
|
||||
"class '_Class implements '_Interface:*Cloneable {\n" +
|
||||
" Object 'CloningMethod:*clone ();\n" +
|
||||
"}",MISC_TYPE),
|
||||
createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.]junit.test.cases"),"public class 'TestCase extends 'TestCaseClazz:*TestCase {\n" +
|
||||
createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.]junit.test.cases"),"public class 'TestCase extends '_TestCaseClazz:*TestCase {\n" +
|
||||
" public void '_testMethod+:test.* ();\n" +
|
||||
"}", MISC_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.singletons"),"class 'Class {\n" +
|
||||
@@ -285,7 +285,7 @@ class JavaPredefinedConfigurations {
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.symbol"),"'Symbol",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields.variables.read"),"'Symbol:[read]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields_variables.with.given.name.pattern.updated"),"'Symbol:[regex( name ) && write]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.usage.of.derived.type.in.cast"),"('CastType:*Base ) 'Expr",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.usage.of.derived.type.in.cast"),"('CastType:*[regex( Base )]) '_Expr",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.declarations"),"'_Type:Object|Integer|Boolean|Long|Character|Short|Byte 'Var = '_Value:[exprtype( int|boolean|long|char|short|byte )]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.declarations"),"'_Type:int|boolean|long|char|short|byte 'Var = '_Value:[exprtype( Integer|Boolean|Long|Character|Short|Byte )]",INTERESTING_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.method.calls"),"'_Instance?.'Call('_BeforeParam*,'_Param:[ exprtype( int|boolean|long|char|short|byte ) && formal( Object|Integer|Boolean|Long|Character|Short|Byte )],'_AfterParam*)",INTERESTING_TYPE),
|
||||
|
||||
+2
-1
@@ -1205,9 +1205,10 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
public void visitIfStatement(final PsiIfStatement if1) {
|
||||
final PsiIfStatement if2 = (PsiIfStatement)myMatchingVisitor.getElement();
|
||||
|
||||
final PsiStatement elseBranch = if1.getElseBranch();
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(if1.getCondition(), if2.getCondition()) &&
|
||||
compareBody(if1.getThenBranch(), if2.getThenBranch()) &&
|
||||
compareBody(if1.getElseBranch(), if2.getElseBranch()));
|
||||
(elseBranch == null || compareBody(elseBranch, if2.getElseBranch())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
package com.intellij.refactoring.typeMigration;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
@@ -65,7 +66,9 @@ public class TypeConversionDescriptor extends TypeConversionDescriptorBase {
|
||||
if (getExpression() != null) expression = getExpression();
|
||||
final Project project = expression.getProject();
|
||||
final ReplaceOptions options = new ReplaceOptions();
|
||||
options.setMatchOptions(new MatchOptions());
|
||||
final MatchOptions matchOptions = new MatchOptions();
|
||||
matchOptions.setFileType(StdFileTypes.JAVA);
|
||||
options.setMatchOptions(matchOptions);
|
||||
final Replacer replacer = new Replacer(project, null);
|
||||
try {
|
||||
final String replacement = replacer.testReplace(expression.getText(), getStringToReplace(), getReplaceByString(), options);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CompileScopeImpl extends CompileScope {
|
||||
@Override
|
||||
public boolean isAffected(BuildTarget<?> target, @NotNull File file) {
|
||||
if (myFiles.isEmpty()) {//optimization
|
||||
return true;
|
||||
return isAffected(target);
|
||||
}
|
||||
final Set<File> files = myFiles.get(target);
|
||||
return files != null && files.contains(file);
|
||||
|
||||
Binary file not shown.
+10
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
|
||||
public class DaemonCodeAnalyzerSettings {
|
||||
@@ -26,9 +26,9 @@ public class DaemonCodeAnalyzerSettings {
|
||||
|
||||
public boolean NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = true;
|
||||
public int AUTOREPARSE_DELAY = 300;
|
||||
public boolean SHOW_ADD_IMPORT_HINTS = true;
|
||||
protected boolean myShowAddImportHints = true;
|
||||
public String NO_AUTO_IMPORT_PATTERN = "[a-z].?";
|
||||
public boolean SUPPRESS_WARNINGS = true;
|
||||
protected boolean mySuppressWarnings = true;
|
||||
public boolean SHOW_METHOD_SEPARATORS = false;
|
||||
public int ERROR_STRIPE_MARK_MIN_HEIGHT = 2;
|
||||
public boolean SHOW_SMALL_ICONS_IN_GUTTER = true;
|
||||
@@ -38,21 +38,21 @@ public class DaemonCodeAnalyzerSettings {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transient
|
||||
@OptionTag(value = "SHOW_ADD_IMPORT_HINTS")
|
||||
public boolean isImportHintEnabled() {
|
||||
return SHOW_ADD_IMPORT_HINTS;
|
||||
return myShowAddImportHints;
|
||||
}
|
||||
|
||||
public void setImportHintEnabled(boolean isImportHintEnabled) {
|
||||
SHOW_ADD_IMPORT_HINTS = isImportHintEnabled;
|
||||
myShowAddImportHints = isImportHintEnabled;
|
||||
}
|
||||
|
||||
@Transient
|
||||
@OptionTag(value = "SUPPRESS_WARNINGS")
|
||||
public boolean isSuppressWarnings() {
|
||||
return SUPPRESS_WARNINGS;
|
||||
return mySuppressWarnings;
|
||||
}
|
||||
|
||||
public void setSuppressWarnings(boolean suppressWarnings) {
|
||||
SUPPRESS_WARNINGS = suppressWarnings;
|
||||
mySuppressWarnings = suppressWarnings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.idea.Main;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.intellij.util.text.StringTokenizer;
|
||||
@@ -28,13 +27,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@@ -55,14 +51,14 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore {
|
||||
public static ClassLoader initClassLoader(boolean updatePlugins) throws MalformedURLException {
|
||||
PathManager.loadProperties();
|
||||
|
||||
List<URL> classpath = new ArrayList<URL>();
|
||||
Collection<URL> classpath = new LinkedHashSet<URL>();
|
||||
addParentClasspath(classpath);
|
||||
addIDEALibraries(classpath);
|
||||
addAdditionalClassPath(classpath);
|
||||
|
||||
UrlClassLoader.Builder builder = UrlClassLoader.build()
|
||||
.urls(filterClassPath(classpath))
|
||||
.allowLock()
|
||||
.urls(filterClassPath(new ArrayList<URL>(classpath)))
|
||||
.allowLock(false)
|
||||
.usePersistentClasspathIndexForLocalClassDirectories()
|
||||
.useCache();
|
||||
if (Boolean.valueOf(System.getProperty(PROPERTY_ALLOW_BOOTSTRAP_RESOURCES, "true"))) {
|
||||
@@ -85,68 +81,35 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore {
|
||||
return newClassLoader;
|
||||
}
|
||||
|
||||
private static List<URL> filterClassPath(List<URL> classpathElements) {
|
||||
String ignoreProperty = System.getProperty(PROPERTY_IGNORE_CLASSPATH);
|
||||
if (ignoreProperty != null) {
|
||||
Pattern pattern = Pattern.compile(ignoreProperty);
|
||||
for (Iterator<URL> i = classpathElements.iterator(); i.hasNext(); ) {
|
||||
String url = i.next().toExternalForm();
|
||||
if (pattern.matcher(url).matches()) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return classpathElements;
|
||||
}
|
||||
|
||||
private static void addParentClasspath(List<URL> classpathElements) throws MalformedURLException {
|
||||
private static void addParentClasspath(Collection<URL> classpath) throws MalformedURLException {
|
||||
List<URLClassLoader> loaders = new ArrayList<URLClassLoader>(2);
|
||||
for (ClassLoader loader = BootstrapClassLoaderUtil.class.getClassLoader(); loader != null; loader = loader.getParent()) {
|
||||
if (loader instanceof URLClassLoader) {
|
||||
ContainerUtil.addAll(classpathElements, ((URLClassLoader)loader).getURLs());
|
||||
loaders.add(0, (URLClassLoader)loader);
|
||||
}
|
||||
else {
|
||||
String loaderName = loader.getClass().getName();
|
||||
try {
|
||||
Class<?> antClassLoaderClass = Class.forName("org.apache.tools.ant.AntClassLoader");
|
||||
if (antClassLoaderClass.isInstance(loader) ||
|
||||
"org.apache.tools.ant.AntClassLoader".equals(loaderName) ||
|
||||
"org.apache.tools.ant.loader.AntClassLoader2".equals(loaderName)) {
|
||||
String classpath = (String)antClassLoaderClass
|
||||
.getDeclaredMethod("getClasspath", ArrayUtil.EMPTY_CLASS_ARRAY)
|
||||
.invoke(loader, ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
StringTokenizer tokenizer = new StringTokenizer(classpath, File.separator, false);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String token = tokenizer.nextToken();
|
||||
classpathElements.add(new File(token).toURI().toURL());
|
||||
}
|
||||
}
|
||||
else {
|
||||
getLogger().warn("Unknown class loader: " + loaderName);
|
||||
}
|
||||
}
|
||||
catch (ClassCastException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
|
||||
catch (ClassNotFoundException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
|
||||
catch (NoSuchMethodException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
|
||||
catch (IllegalAccessException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
|
||||
catch (InvocationTargetException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
|
||||
getLogger().warn("Unknown class loader: " + loader.getClass().getName());
|
||||
}
|
||||
}
|
||||
for (URLClassLoader loader : loaders) {
|
||||
ContainerUtil.addAll(classpath, loader.getURLs());
|
||||
}
|
||||
}
|
||||
|
||||
private static void addIDEALibraries(List<URL> classpathElements) throws MalformedURLException {
|
||||
private static void addIDEALibraries(Collection<URL> classpath) throws MalformedURLException {
|
||||
Class<BootstrapClassLoaderUtil> aClass = BootstrapClassLoaderUtil.class;
|
||||
String selfRoot = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
|
||||
assert selfRoot != null;
|
||||
URL selfRootUrl = new File(selfRoot).getAbsoluteFile().toURI().toURL();
|
||||
classpathElements.add(selfRootUrl);
|
||||
classpath.add(selfRootUrl);
|
||||
|
||||
File libFolder = new File(PathManager.getLibPath());
|
||||
addLibraries(classpathElements, libFolder, selfRootUrl);
|
||||
addLibraries(classpathElements, new File(libFolder, "ext"), selfRootUrl);
|
||||
addLibraries(classpathElements, new File(libFolder, "ant/lib"), selfRootUrl);
|
||||
addLibraries(classpath, libFolder, selfRootUrl);
|
||||
addLibraries(classpath, new File(libFolder, "ext"), selfRootUrl);
|
||||
addLibraries(classpath, new File(libFolder, "ant/lib"), selfRootUrl);
|
||||
}
|
||||
|
||||
private static void addLibraries(List<URL> classPath, File fromDir, URL selfRootUrl) throws MalformedURLException {
|
||||
private static void addLibraries(Collection<URL> classPath, File fromDir, URL selfRootUrl) throws MalformedURLException {
|
||||
File[] files = fromDir.listFiles();
|
||||
if (files == null) return;
|
||||
|
||||
@@ -160,16 +123,30 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addAdditionalClassPath(List<URL> classPath) {
|
||||
private static void addAdditionalClassPath(Collection<URL> classpath) {
|
||||
try {
|
||||
StringTokenizer tokenizer = new StringTokenizer(System.getProperty(PROPERTY_ADDITIONAL_CLASSPATH, ""), File.pathSeparator, false);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String pathItem = tokenizer.nextToken();
|
||||
classPath.add(new File(pathItem).toURI().toURL());
|
||||
classpath.add(new File(pathItem).toURI().toURL());
|
||||
}
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
getLogger().error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<URL> filterClassPath(List<URL> classpath) {
|
||||
String ignoreProperty = System.getProperty(PROPERTY_IGNORE_CLASSPATH);
|
||||
if (ignoreProperty != null) {
|
||||
Pattern pattern = Pattern.compile(ignoreProperty);
|
||||
for (Iterator<URL> i = classpath.iterator(); i.hasNext(); ) {
|
||||
String url = i.next().toExternalForm();
|
||||
if (pattern.matcher(url).matches()) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return classpath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -23,27 +23,52 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Tracks the correspondence between {@link VirtualFile} instances and corresponding {@link Document} instances.
|
||||
* Manages the saving of changes to disk.
|
||||
*/
|
||||
public abstract class FileDocumentManager implements SavingRequestor {
|
||||
@NotNull
|
||||
public static FileDocumentManager getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(FileDocumentManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document for the specified virtual file.
|
||||
* @param file the file for which the document is requested.
|
||||
* @return the document, or null if the file represents a directory, or is binary without an associated decompiler,
|
||||
* or is too large.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract Document getDocument(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the document for the specified file which has already been loaded into memory.
|
||||
*
|
||||
* @param file the file for which the document is requested.
|
||||
* @return the document, or null if the specified virtual file hasn't been loaded into memory.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract Document getCachedDocument(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the virtual file corresponding to the specified document.
|
||||
*
|
||||
* @param document the document for which the virtual file is requested.
|
||||
* @return the file, or null if the document wasn't created from a virtual file.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract VirtualFile getFile(@NotNull Document document);
|
||||
|
||||
/**
|
||||
* This operation can modify documents that will be saved (due to 'Trip trailing spaces on Save' functionality).
|
||||
* Saves all unsaved documents to disk. This operation can modify documents that will be saved
|
||||
* (due to 'Strip trailing spaces on Save' functionality).
|
||||
*/
|
||||
public abstract void saveAllDocuments();
|
||||
|
||||
/**
|
||||
* This operation can modify the document (due to 'Trip trailing spaces on Save' functionality).
|
||||
* Saves the specified document to disk. This operation can modify the document (due to 'Strip
|
||||
* trailing spaces on Save' functionality).
|
||||
*/
|
||||
public abstract void saveDocument(@NotNull Document document);
|
||||
|
||||
@@ -52,12 +77,35 @@ public abstract class FileDocumentManager implements SavingRequestor {
|
||||
* @param document the document to save.
|
||||
*/
|
||||
public abstract void saveDocumentAsIs(@NotNull Document document);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ist of all documents that have unsaved changes.
|
||||
* @return the documents that have unsaved changes.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract Document[] getUnsavedDocuments();
|
||||
|
||||
/**
|
||||
* Checks if the document has unsaved changes.
|
||||
*
|
||||
* @param document the document to check.
|
||||
* @return true if the document has unsaved changes, false otherwise.
|
||||
*/
|
||||
public abstract boolean isDocumentUnsaved(@NotNull Document document);
|
||||
|
||||
/**
|
||||
* Checks if the document corresponding to the specified file has unsaved changes.
|
||||
*
|
||||
* @param file the file to check.
|
||||
* @return true if the file has unsaved changes, false otherwise.
|
||||
*/
|
||||
public abstract boolean isFileModified(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Discards unsaved changes for the specified document and reloads it from disk.
|
||||
*
|
||||
* @param document the document to reload.
|
||||
*/
|
||||
public abstract void reloadFromDisk(@NotNull Document document);
|
||||
|
||||
@NotNull
|
||||
@@ -77,5 +125,10 @@ public abstract class FileDocumentManager implements SavingRequestor {
|
||||
return getInstance().requestWriting(document, project);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discards unsaved changes for the specified files.
|
||||
*
|
||||
* @param files the files to discard the changes for.
|
||||
*/
|
||||
public abstract void reloadFiles(@NotNull VirtualFile... files);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.NotNullLazyKey;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.messages.Topic;
|
||||
@@ -37,9 +38,6 @@ import java.util.List;
|
||||
* A service managing IDEA's 'dumb' mode: when indices are updated in background and the functionality is very much limited.
|
||||
* Only the explicitly allowed functionality is available. Usually it's allowed by implementing {@link DumbAware} interface.
|
||||
*
|
||||
* If you want to register a toolwindow, which will be enabled during the dumb mode, please use {@link com.intellij.openapi.wm.ToolWindowManager}'s
|
||||
* registration methods which have 'canWorkInDumMode' parameter.
|
||||
*
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class DumbService {
|
||||
@@ -50,6 +48,11 @@ public abstract class DumbService {
|
||||
*/
|
||||
public static final Topic<DumbModeListener> DUMB_MODE = new Topic<DumbModeListener>("dumb mode", DumbModeListener.class);
|
||||
|
||||
/**
|
||||
* The tracker is advanced each time we enter/exit from dumb mode.
|
||||
*/
|
||||
public abstract ModificationTracker getModificationTracker();
|
||||
|
||||
/**
|
||||
* @return whether IntelliJ IDEA is in dumb mode, which means that right now indices are updated in background.
|
||||
* IDEA offers only limited functionality at such times, e.g. plain text file editing and version control operations.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,13 @@ import java.util.EventListener;
|
||||
* Manages the relationship between documents and PSI trees.
|
||||
*/
|
||||
public abstract class PsiDocumentManager {
|
||||
/**
|
||||
* Checks if the PSI tree for the specified document is up to date (its state reflects the latest changes made
|
||||
* to the document content).
|
||||
*
|
||||
* @param document the document to check.
|
||||
* @return true if the PSI tree for the document is up to date, false otherwise.
|
||||
*/
|
||||
public abstract boolean isCommitted(@NotNull Document document);
|
||||
|
||||
/**
|
||||
@@ -206,8 +213,22 @@ public abstract class PsiDocumentManager {
|
||||
*/
|
||||
public abstract void removeListener(@NotNull Listener listener);
|
||||
|
||||
/**
|
||||
* Checks if the PSI tree corresponding to the specified document has been modified and the changes have not
|
||||
* yet been applied to the document. Documents in that state cannot be modified directly, because such changes
|
||||
* would conflict with the pending PSI changes. Changes made through PSI are always applied in the end of a write action,
|
||||
* and can be applied in the middle of a write action by calling {@link #doPostponedOperationsAndUnblockDocument}.
|
||||
*
|
||||
* @param doc the document to check.
|
||||
* @return true if the corresponding PSI has changes that haven't been applied to the document.
|
||||
*/
|
||||
public abstract boolean isDocumentBlockedByPsi(@NotNull Document doc);
|
||||
|
||||
/**
|
||||
* Applies pending changes made through the PSI to the specified document.
|
||||
*
|
||||
* @param doc the document to apply the changes to.
|
||||
*/
|
||||
public abstract void doPostponedOperationsAndUnblockDocument(@NotNull Document doc);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -19,7 +19,6 @@ import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A PSI element representing a file.
|
||||
@@ -101,5 +100,9 @@ public interface PsiFile extends PsiFileSystemItem {
|
||||
@Override
|
||||
FileASTNode getNode();
|
||||
|
||||
/**
|
||||
* Called by the PSI framework when the contents of the file changes. Can be used to invalidate
|
||||
* file-level caches. If you override this method, you <b>must</b> call the base class implementation.
|
||||
*/
|
||||
void subtreeChanged();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.intellij.openapi.project.DumbModeTask;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.SimpleModificationTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -36,6 +38,11 @@ public class MockDumbService extends DumbService {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationTracker getModificationTracker() {
|
||||
return new SimpleModificationTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumb() {
|
||||
return false;
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.diff.tools.external.ExternalDiffTool;
|
||||
import com.intellij.diff.tools.fragmented.OnesideDiffTool;
|
||||
import com.intellij.diff.tools.simple.SimpleDiffTool;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,11 +33,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DiffManagerImpl extends DiffManagerEx {
|
||||
private static final Logger LOG = Logger.getInstance(DiffManagerImpl.class);
|
||||
|
||||
@Override
|
||||
public void showDiff(@Nullable Project project, @NotNull DiffRequest request) {
|
||||
showDiff(project, request, DiffDialogHints.DEFAULT);
|
||||
@@ -88,16 +86,11 @@ public class DiffManagerImpl extends DiffManagerEx {
|
||||
@Override
|
||||
public List<DiffTool> getDiffTools() {
|
||||
List<DiffTool> result = new ArrayList<DiffTool>();
|
||||
|
||||
result.add(SimpleDiffTool.INSTANCE);
|
||||
result.add(OnesideDiffTool.INSTANCE);
|
||||
result.add(BinaryDiffTool.INSTANCE);
|
||||
result.add(DirDiffTool.INSTANCE);
|
||||
|
||||
for (DiffTool tool : DiffTool.EP_NAME.getExtensions()) {
|
||||
result.add(tool);
|
||||
}
|
||||
|
||||
Collections.addAll(result, DiffTool.EP_NAME.getExtensions());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,31 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
|
||||
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
|
||||
String text = getTemplatePresentation().getText();
|
||||
if (files != null && files.length == 1) text += "...";
|
||||
String text = "Compare Files";
|
||||
if (files != null && files.length == 1) {
|
||||
text = "Compare With...";
|
||||
}
|
||||
else if (files != null && files.length == 2) {
|
||||
Type type1 = getType(files[0]);
|
||||
Type type2 = getType(files[1]);
|
||||
|
||||
if (type1 != type2) {
|
||||
text = "Compare";
|
||||
}
|
||||
else {
|
||||
switch (type1) {
|
||||
case FILE:
|
||||
text = "Compare Files";
|
||||
break;
|
||||
case DIRECTORY:
|
||||
text = "Compare Directories";
|
||||
break;
|
||||
case ARCHIEVE:
|
||||
text = "Compare Archieves";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
e.getPresentation().setText(text);
|
||||
}
|
||||
|
||||
@@ -93,7 +116,9 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
private static VirtualFile getOtherFile(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
FileChooserDescriptor descriptor;
|
||||
String key;
|
||||
if (file.isDirectory() || file.getFileType() instanceof ArchiveFileType) {
|
||||
|
||||
Type type = getType(file);
|
||||
if (type == Type.DIRECTORY || type == Type.ARCHIEVE) {
|
||||
descriptor = new FileChooserDescriptor(false, true, true, false, false, false);
|
||||
key = LAST_USED_FOLDER_KEY;
|
||||
}
|
||||
@@ -121,4 +146,14 @@ public class CompareFilesAction extends BaseShowDiffAction {
|
||||
if (project == null) return;
|
||||
PropertiesComponent.getInstance(project).setValue(key, file.getPath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Type getType(@Nullable VirtualFile file) {
|
||||
if (file == null) return Type.FILE;
|
||||
if (file.isDirectory()) return Type.DIRECTORY;
|
||||
if (file.getFileType() instanceof ArchiveFileType) return Type.ARCHIEVE;
|
||||
return Type.FILE;
|
||||
}
|
||||
|
||||
private enum Type {FILE, DIRECTORY, ARCHIEVE}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ErrorDiffTool implements FrameDiffTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Error Viewer";
|
||||
return "Error viewer";
|
||||
}
|
||||
|
||||
private static class MyViewer implements DiffViewer {
|
||||
|
||||
@@ -37,6 +37,6 @@ public class BinaryDiffTool implements FrameDiffTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Binary File Viewer";
|
||||
return "Binary file viewer";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,17 +23,21 @@ import com.intellij.diff.contents.EmptyContent;
|
||||
import com.intellij.diff.contents.FileContent;
|
||||
import com.intellij.diff.requests.ContentDiffRequest;
|
||||
import com.intellij.diff.requests.DiffRequest;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.diff.DiffElement;
|
||||
import com.intellij.ide.diff.DirDiffSettings;
|
||||
import com.intellij.ide.diff.JarFileDiffElement;
|
||||
import com.intellij.ide.diff.VirtualFileDiffElement;
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffFrame;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffPanel;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
|
||||
import com.intellij.openapi.diff.impl.dir.DirDiffWindow;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -46,7 +50,8 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
@NotNull private final DiffContext myContext;
|
||||
@NotNull private final ContentDiffRequest myRequest;
|
||||
|
||||
@NotNull private final DirDiffPanel myPanel;
|
||||
@NotNull private final DirDiffPanel myDirDiffPanel;
|
||||
@NotNull private final JPanel myPanel;
|
||||
|
||||
public DifDiffViewer(@NotNull DiffContext context, @NotNull ContentDiffRequest request) {
|
||||
myContext = context;
|
||||
@@ -57,7 +62,7 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
DiffElement element2 = createDiffElement(contents.get(1));
|
||||
DirDiffTableModel model = new DirDiffTableModel(context.getProject(), element1, element2, new DirDiffSettings());
|
||||
|
||||
myPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) {
|
||||
myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) {
|
||||
@Override
|
||||
public Window getWindow() {
|
||||
return null;
|
||||
@@ -72,31 +77,43 @@ class DifDiffViewer implements FrameDiffTool.DiffViewer {
|
||||
public void setTitle(String title) {
|
||||
}
|
||||
});
|
||||
|
||||
myPanel = new JPanel(new BorderLayout());
|
||||
myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(myPanel, new DataProvider() {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (PlatformDataKeys.HELP_ID.is(dataId)) {
|
||||
return "reference.dialogs.diff.folder";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FrameDiffTool.ToolbarComponents init() {
|
||||
myPanel.setupSplitter();
|
||||
myDirDiffPanel.setupSplitter();
|
||||
|
||||
return new FrameDiffTool.ToolbarComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
Disposer.dispose(myPanel);
|
||||
Disposer.dispose(myDirDiffPanel);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myPanel.getPanel();
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myPanel.getTable();
|
||||
return myDirDiffPanel.getTable();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -38,6 +38,6 @@ public class DirDiffTool implements FrameDiffTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Directory Viewer";
|
||||
return "Directory viewer";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ public class OnesideDiffTool implements FrameDiffTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Oneside Viewer";
|
||||
return "Oneside viewer";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,6 @@ public class SimpleDiffTool implements FrameDiffTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Default Viewer";
|
||||
return "Default viewer";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ package com.intellij.diff.tools.util.base;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum HighlightPolicy {
|
||||
DO_NOT_HIGHLIGHT("Do Not Highlight"),
|
||||
BY_LINE("By Line"),
|
||||
BY_WORD("By Word"),
|
||||
BY_WORD_SPLIT("By Word In Chunks");
|
||||
DO_NOT_HIGHLIGHT("Do not highlight"),
|
||||
BY_LINE("Highlight words"),
|
||||
BY_WORD("Highlight lines"),
|
||||
BY_WORD_SPLIT("Highlight split changes");
|
||||
|
||||
@NotNull private final String myText;
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ import com.intellij.diff.comparison.ComparisonPolicy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum IgnorePolicy {
|
||||
DEFAULT("Do Not Ignore"),
|
||||
TRIM_WHITESPACES("Trim Whitespaces"),
|
||||
IGNORE_WHITESPACES("Ignore Whitespaces"),
|
||||
IGNORE_WHITESPACES_CHUNKS("Ignore Whitespaces And Empty Lines");
|
||||
DEFAULT("Do not ignore"),
|
||||
TRIM_WHITESPACES("Trim whitespaces"),
|
||||
IGNORE_WHITESPACES("Ignore whitespaces"),
|
||||
IGNORE_WHITESPACES_CHUNKS("Ignore whitespaces and empty lines");
|
||||
|
||||
@NotNull private final String myText;
|
||||
|
||||
|
||||
+3
-3
@@ -31,15 +31,15 @@ import java.util.Map;
|
||||
|
||||
@State(
|
||||
name = "TextDiffSettings",
|
||||
storages = {@Storage(
|
||||
file = DiffUtil.DIFF_CONFIG)})
|
||||
storages = @Storage(file = DiffUtil.DIFF_CONFIG)
|
||||
)
|
||||
public class TextDiffSettingsHolder implements PersistentStateComponent<TextDiffSettingsHolder.State> {
|
||||
public static final Key<TextDiffSettings> KEY = Key.create("TextDiffSettings");
|
||||
|
||||
public static final int[] CONTEXT_RANGE_MODES = {1, 2, 4, 8, -1};
|
||||
public static final String[] CONTEXT_RANGE_MODE_LABELS = {"1", "2", "4", "8", "Disable"};
|
||||
|
||||
private static class SharedSettings {
|
||||
private final static class SharedSettings {
|
||||
// Fragments settings
|
||||
public int CONTEXT_RANGE = 4;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.dvcs;
|
||||
|
||||
import com.intellij.ide.SaveAndSyncHandler;
|
||||
import com.intellij.ide.SaveAndSyncHandlerImpl;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -133,7 +132,7 @@ public abstract class DvcsPlatformFacadeImpl implements DvcsPlatformFacade {
|
||||
@NotNull
|
||||
@Override
|
||||
public SaveAndSyncHandler getSaveAndSyncHandler() {
|
||||
return SaveAndSyncHandlerImpl.getInstance();
|
||||
return SaveAndSyncHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -184,7 +184,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
|
||||
|
||||
public static class FontFilter implements SerializationFilter {
|
||||
@Override
|
||||
public boolean accepts(@NotNull Accessor accessor, Object bean) {
|
||||
public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
|
||||
UISettings settings = (UISettings)bean;
|
||||
return !hasDefaultFontSetting(settings);
|
||||
}
|
||||
|
||||
+49
-20
@@ -40,12 +40,23 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
|
||||
@NotNull private S myInitialSettings;
|
||||
|
||||
@Nullable
|
||||
private JBCheckBox myUseAutoImportBox;
|
||||
@Nullable
|
||||
private JBCheckBox myCreateEmptyContentRootDirectoriesBox;
|
||||
private boolean myHideUseAutoImportBox;
|
||||
@NotNull
|
||||
private ExternalSystemSettingsControlCustomizer myCustomizer;
|
||||
|
||||
protected AbstractExternalProjectSettingsControl(@NotNull S initialSettings) {
|
||||
this(null, initialSettings, null);
|
||||
}
|
||||
|
||||
protected AbstractExternalProjectSettingsControl(@Nullable Project project,
|
||||
@NotNull S initialSettings,
|
||||
@Nullable ExternalSystemSettingsControlCustomizer controlCustomizer) {
|
||||
myProject = project;
|
||||
myInitialSettings = initialSettings;
|
||||
myCustomizer = controlCustomizer == null ? new ExternalSystemSettingsControlCustomizer() : controlCustomizer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -53,27 +64,31 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
return myInitialSettings;
|
||||
}
|
||||
|
||||
public void hideUseAutoImportBox() {
|
||||
myHideUseAutoImportBox = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillUi(@NotNull PaintAwarePanel canvas, int indentLevel) {
|
||||
myUseAutoImportBox = new JBCheckBox(ExternalSystemBundle.message("settings.label.use.auto.import"));
|
||||
myUseAutoImportBox.setVisible(!myHideUseAutoImportBox);
|
||||
canvas.add(myUseAutoImportBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
myCreateEmptyContentRootDirectoriesBox =
|
||||
new JBCheckBox(ExternalSystemBundle.message("settings.label.create.empty.content.root.directories"));
|
||||
canvas.add(myCreateEmptyContentRootDirectoriesBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
if (!myCustomizer.isUseAutoImportBoxHidden()) {
|
||||
myUseAutoImportBox = new JBCheckBox(ExternalSystemBundle.message("settings.label.use.auto.import"));
|
||||
canvas.add(myUseAutoImportBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
}
|
||||
if (!myCustomizer.isCreateEmptyContentRootDirectoriesBoxHidden()) {
|
||||
myCreateEmptyContentRootDirectoriesBox =
|
||||
new JBCheckBox(ExternalSystemBundle.message("settings.label.create.empty.content.root.directories"));
|
||||
canvas.add(myCreateEmptyContentRootDirectoriesBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
}
|
||||
fillExtraControls(canvas, indentLevel);
|
||||
}
|
||||
|
||||
protected abstract void fillExtraControls(@NotNull PaintAwarePanel content, int indentLevel);
|
||||
|
||||
public boolean isModified() {
|
||||
return myUseAutoImportBox.isSelected() != getInitialSettings().isUseAutoImport()
|
||||
|| myCreateEmptyContentRootDirectoriesBox.isSelected() != getInitialSettings().isCreateEmptyContentRootDirectories()
|
||||
|| isExtraSettingModified();
|
||||
boolean result = false;
|
||||
if (!myCustomizer.isUseAutoImportBoxHidden() && myUseAutoImportBox != null) {
|
||||
result = myUseAutoImportBox.isSelected() != getInitialSettings().isUseAutoImport();
|
||||
}
|
||||
if (!myCustomizer.isCreateEmptyContentRootDirectoriesBoxHidden() && myCreateEmptyContentRootDirectoriesBox != null) {
|
||||
result = result || myCreateEmptyContentRootDirectoriesBox.isSelected() != getInitialSettings().isCreateEmptyContentRootDirectories();
|
||||
}
|
||||
return result || isExtraSettingModified();
|
||||
}
|
||||
|
||||
protected abstract boolean isExtraSettingModified();
|
||||
@@ -83,8 +98,12 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
}
|
||||
|
||||
public void reset(boolean isDefaultModuleCreation) {
|
||||
myUseAutoImportBox.setSelected(getInitialSettings().isUseAutoImport());
|
||||
myCreateEmptyContentRootDirectoriesBox.setSelected(getInitialSettings().isCreateEmptyContentRootDirectories());
|
||||
if (!myCustomizer.isUseAutoImportBoxHidden() && myUseAutoImportBox != null) {
|
||||
myUseAutoImportBox.setSelected(getInitialSettings().isUseAutoImport());
|
||||
}
|
||||
if (!myCustomizer.isCreateEmptyContentRootDirectoriesBoxHidden() && myCreateEmptyContentRootDirectoriesBox != null) {
|
||||
myCreateEmptyContentRootDirectoriesBox.setSelected(getInitialSettings().isCreateEmptyContentRootDirectories());
|
||||
}
|
||||
resetExtraSettings(isDefaultModuleCreation);
|
||||
}
|
||||
|
||||
@@ -92,8 +111,13 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
|
||||
@Override
|
||||
public void apply(@NotNull S settings) {
|
||||
settings.setUseAutoImport(myUseAutoImportBox.isSelected());
|
||||
settings.setCreateEmptyContentRootDirectories(myCreateEmptyContentRootDirectoriesBox.isSelected());
|
||||
if (!myCustomizer.isUseAutoImportBoxHidden() && myUseAutoImportBox != null) {
|
||||
settings.setUseAutoImport(myUseAutoImportBox.isSelected());
|
||||
}
|
||||
|
||||
if (!myCustomizer.isCreateEmptyContentRootDirectoriesBoxHidden() && myCreateEmptyContentRootDirectoriesBox != null) {
|
||||
settings.setCreateEmptyContentRootDirectories(myCreateEmptyContentRootDirectoriesBox.isSelected());
|
||||
}
|
||||
if (myInitialSettings.getExternalProjectPath() != null) {
|
||||
settings.setExternalProjectPath(myInitialSettings.getExternalProjectPath());
|
||||
}
|
||||
@@ -112,8 +136,13 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
}
|
||||
|
||||
public void updateInitialSettings() {
|
||||
myInitialSettings.setUseAutoImport(myUseAutoImportBox.isSelected());
|
||||
myInitialSettings.setCreateEmptyContentRootDirectories(myCreateEmptyContentRootDirectoriesBox.isSelected());
|
||||
if (!myCustomizer.isUseAutoImportBoxHidden() && myUseAutoImportBox != null) {
|
||||
myInitialSettings.setUseAutoImport(myUseAutoImportBox.isSelected());
|
||||
}
|
||||
|
||||
if (!myCustomizer.isCreateEmptyContentRootDirectoriesBoxHidden() && myCreateEmptyContentRootDirectoriesBox != null) {
|
||||
myInitialSettings.setCreateEmptyContentRootDirectories(myCreateEmptyContentRootDirectoriesBox.isSelected());
|
||||
}
|
||||
updateInitialExtraSettings();
|
||||
}
|
||||
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.service.settings;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 2/24/2015
|
||||
*/
|
||||
public class ExternalSystemSettingsControlCustomizer {
|
||||
|
||||
private boolean hideUseAutoImportBox;
|
||||
private boolean hideCreateEmptyContentRootDirectoriesBox;
|
||||
|
||||
public ExternalSystemSettingsControlCustomizer() {
|
||||
}
|
||||
|
||||
public ExternalSystemSettingsControlCustomizer(boolean hideUseAutoImportBox, boolean hideCreateEmptyContentRootDirectoriesBox) {
|
||||
this.hideUseAutoImportBox = hideUseAutoImportBox;
|
||||
this.hideCreateEmptyContentRootDirectoriesBox = hideCreateEmptyContentRootDirectoriesBox;
|
||||
}
|
||||
|
||||
public boolean isUseAutoImportBoxHidden() {
|
||||
return hideUseAutoImportBox;
|
||||
}
|
||||
|
||||
public boolean isCreateEmptyContentRootDirectoriesBoxHidden() {
|
||||
return hideCreateEmptyContentRootDirectoriesBox;
|
||||
}
|
||||
}
|
||||
+1
@@ -92,6 +92,7 @@ public class ExternalSystemJdkComboBox extends ComboBoxWithWidePopup {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExternalSystemJdkComboBox withoutJre() {
|
||||
suggestJre = false;
|
||||
return this;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
@@ -130,32 +131,39 @@ class ExportToHTMLManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean exportPsiFile(final PsiFile psiFile, String outputDirectoryName, Project project, HashMap<PsiFile, PsiFile> filesMap) {
|
||||
ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project);
|
||||
private static boolean exportPsiFile(final PsiFile psiFile,
|
||||
final String outputDirectoryName,
|
||||
final Project project,
|
||||
final HashMap<PsiFile, PsiFile> filesMap) {
|
||||
final ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project);
|
||||
|
||||
if (psiFile instanceof PsiBinaryFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TreeMap<Integer, PsiReference> refMap = null;
|
||||
for (PrintOption printOption : Extensions.getExtensions(PrintOption.EP_NAME)) {
|
||||
final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
|
||||
if (map != null) {
|
||||
refMap = new TreeMap<Integer, PsiReference>();
|
||||
refMap.putAll(map);
|
||||
}
|
||||
}
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TreeMap<Integer, PsiReference> refMap = null;
|
||||
for (PrintOption printOption : Extensions.getExtensions(PrintOption.EP_NAME)) {
|
||||
final TreeMap<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
|
||||
if (map != null) {
|
||||
refMap = new TreeMap<Integer, PsiReference>();
|
||||
refMap.putAll(map);
|
||||
}
|
||||
}
|
||||
|
||||
String dirName = constructOutputDirectory(psiFile, outputDirectoryName);
|
||||
HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS);
|
||||
try {
|
||||
textPainter.paint(refMap, psiFile.getFileType());
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
myLastException = e;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
String dirName = constructOutputDirectory(psiFile, outputDirectoryName);
|
||||
HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS);
|
||||
try {
|
||||
textPainter.paint(refMap, psiFile.getFileType());
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
myLastException = e;
|
||||
}
|
||||
}
|
||||
});
|
||||
return myLastException == null;
|
||||
}
|
||||
|
||||
private static String constructOutputDirectory(PsiFile psiFile, String outputDirectoryName) {
|
||||
@@ -241,11 +249,18 @@ class ExportToHTMLManager {
|
||||
final ArrayList<PsiFile> filesList = new ArrayList<PsiFile>();
|
||||
final boolean isRecursive = myExportToHTMLSettings.isIncludeSubdirectories();
|
||||
|
||||
try {
|
||||
addToPsiFileList(myPsiDirectory, filesList, isRecursive, myOutputDirectoryName);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
myLastException = e;
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
addToPsiFileList(myPsiDirectory, filesList, isRecursive, myOutputDirectoryName);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
myLastException = e;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (myLastException != null) {
|
||||
return;
|
||||
}
|
||||
HashMap<PsiFile, PsiFile> filesMap = new HashMap<PsiFile, PsiFile>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,21 +21,32 @@
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.codeInsight.daemon.impl.LineMarkersPass;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class FileSeparatorProvider {
|
||||
public static FileSeparatorProvider getInstance() {
|
||||
return ServiceManager.getService(FileSeparatorProvider.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<LineMarkerInfo> getFileSeparators(PsiFile file, final Document document, @Nullable final Editor editor) {
|
||||
return null;
|
||||
public static List<LineMarkerInfo> getFileSeparators(PsiFile file, final Document document) {
|
||||
final List<LineMarkerInfo> result = new ArrayList<LineMarkerInfo>();
|
||||
LineMarkersPass pass = new LineMarkersPass(file.getProject(), file, null, document, file.getTextRange());
|
||||
for (LineMarkerInfo lineMarkerInfo : pass.queryLineMarkers()) {
|
||||
if (lineMarkerInfo.separatorColor != null) {
|
||||
result.add(lineMarkerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<LineMarkerInfo>() {
|
||||
public int compare(final LineMarkerInfo i1, final LineMarkerInfo i2) {
|
||||
return i1.startOffset - i2.startOffset;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -35,7 +35,6 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.impl.file.PsiDirectoryFactory;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.ui.JBColor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -86,8 +85,7 @@ class HTMLTextPainter {
|
||||
|
||||
ArrayList<LineMarkerInfo> methodSeparators = new ArrayList<LineMarkerInfo>();
|
||||
if (document != null) {
|
||||
final List<LineMarkerInfo> separators = FileSeparatorProvider.getInstance().getFileSeparators(psiFile, document,
|
||||
PsiUtilBase.findEditor(psiFile));
|
||||
final List<LineMarkerInfo> separators = FileSeparatorProvider.getFileSeparators(psiFile, document);
|
||||
if (separators != null) {
|
||||
methodSeparators.addAll(separators);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -100,7 +100,7 @@ class TextPainter extends BasePainter {
|
||||
FileType fileType,
|
||||
Editor editor) {
|
||||
this(editorDocument, highlighter, fullFileName, shortFileName, psiFile.getProject(), fileType,
|
||||
FileSeparatorProvider.getInstance().getFileSeparators(psiFile, editorDocument, editor));
|
||||
FileSeparatorProvider.getFileSeparators(psiFile, editorDocument));
|
||||
}
|
||||
|
||||
public TextPainter(@NotNull DocumentEx editorDocument,
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<text value="Scope:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1fda7" class="javax.swing.JLabel">
|
||||
<component id="1fda7" class="javax.swing.JLabel" binding="myOptionalLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
||||
@@ -51,6 +51,7 @@ public class LayoutCodeDialog extends DialogWrapper {
|
||||
|
||||
private JPanel myActionsPanel;
|
||||
private JPanel myScopePanel;
|
||||
private JLabel myOptionalLabel;
|
||||
|
||||
private LayoutCodeOptions myRunOptions;
|
||||
|
||||
@@ -127,6 +128,8 @@ public class LayoutCodeDialog extends DialogWrapper {
|
||||
if (canRearrangeCode) {
|
||||
myRearrangeCodeCb.setSelected(myLastRunOptions.isRearrangeCode(myFile.getLanguage()));
|
||||
}
|
||||
|
||||
myOptionalLabel.setVisible(canOptimizeImports || canRearrangeCode);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -24,13 +24,13 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManagerImpl;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
|
||||
@State(
|
||||
name = "DaemonCodeAnalyzerSettings",
|
||||
storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml")}
|
||||
storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml")
|
||||
)
|
||||
public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings implements PersistentStateComponent<Element>, Cloneable {
|
||||
@Override
|
||||
@@ -42,7 +42,7 @@ public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings i
|
||||
public DaemonCodeAnalyzerSettingsImpl clone() {
|
||||
DaemonCodeAnalyzerSettingsImpl settings = new DaemonCodeAnalyzerSettingsImpl();
|
||||
settings.AUTOREPARSE_DELAY = AUTOREPARSE_DELAY;
|
||||
settings.SHOW_ADD_IMPORT_HINTS = SHOW_ADD_IMPORT_HINTS;
|
||||
settings.myShowAddImportHints = myShowAddImportHints;
|
||||
settings.SHOW_METHOD_SEPARATORS = SHOW_METHOD_SEPARATORS;
|
||||
settings.NO_AUTO_IMPORT_PATTERN = NO_AUTO_IMPORT_PATTERN;
|
||||
settings.SHOW_SMALL_ICONS_IN_GUTTER = SHOW_SMALL_ICONS_IN_GUTTER;
|
||||
@@ -51,7 +51,7 @@ public class DaemonCodeAnalyzerSettingsImpl extends DaemonCodeAnalyzerSettings i
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element element = XmlSerializer.serialize(this, new SkipDefaultValuesSerializationFilters());
|
||||
Element element = XmlSerializer.serialize(this, new SkipDefaultsSerializationFilter());
|
||||
String profile = InspectionProfileManager.getInstance().getRootProfile().getName();
|
||||
if (!"Default".equals(profile)) {
|
||||
element.setAttribute("profile", profile);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class LineMarkersPass extends TextEditorHighlightingPass implements LineM
|
||||
myMarkers = mergeLineMarkers(lineMarkers, myEditor);
|
||||
}
|
||||
|
||||
static List<LineMarkerInfo> mergeLineMarkers(@NotNull List<LineMarkerInfo> markers, Editor editor) {
|
||||
static List<LineMarkerInfo> mergeLineMarkers(@NotNull List<LineMarkerInfo> markers, @Nullable Editor editor) {
|
||||
List<MergeableLineMarkerInfo> forMerge = new ArrayList<MergeableLineMarkerInfo>();
|
||||
final Iterator<LineMarkerInfo> iterator = markers.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -40,6 +40,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.actions.EditorActionUtil;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -78,7 +79,8 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
|
||||
@NotNull
|
||||
public static List<HighlightInfo.IntentionActionDescriptor> getAvailableActions(@NotNull final Editor editor, @NotNull final PsiFile file, final int passId) {
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
final Integer expectedCaretOffset = editor.getUserData(EditorActionUtil.EXPECTED_CARET_OFFSET);
|
||||
final int offset = expectedCaretOffset != null ? expectedCaretOffset : editor.getCaretModel().getOffset();
|
||||
final Project project = file.getProject();
|
||||
|
||||
final List<HighlightInfo.IntentionActionDescriptor> result = new ArrayList<HighlightInfo.IntentionActionDescriptor>();
|
||||
|
||||
@@ -356,7 +356,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
commentContext.docStart = false;
|
||||
}
|
||||
else {
|
||||
commentContext.docAsterisk = true;
|
||||
commentContext.docAsterisk = CodeStyleSettingsManager.getSettings(getProject()).JD_LEADING_ASTERISKS_ARE_ENABLED;
|
||||
commentContext.docStart = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,12 +452,10 @@ public class TemplateSettings implements PersistentStateComponent<TemplateSettin
|
||||
}
|
||||
}
|
||||
|
||||
private void readDefTemplate(DefaultLiveTemplatesProvider provider, String defTemplate, boolean registerTemplate)
|
||||
throws JDOMException, InvalidDataException, IOException {
|
||||
String templateName = getDefaultTemplateName(defTemplate);
|
||||
private void readDefTemplate(DefaultLiveTemplatesProvider provider, String defTemplate, boolean registerTemplate) throws JDOMException, InvalidDataException, IOException {
|
||||
InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, defTemplate);
|
||||
if (inputStream != null) {
|
||||
TemplateGroup group = readTemplateFile(JDOMUtil.load(inputStream), templateName, true, registerTemplate, provider.getClass().getClassLoader());
|
||||
TemplateGroup group = readTemplateFile(JDOMUtil.load(inputStream), getDefaultTemplateName(defTemplate), true, registerTemplate, provider.getClass().getClassLoader());
|
||||
if (group != null && group.getReplace() != null) {
|
||||
for (TemplateImpl template : myTemplates.get(group.getReplace())) {
|
||||
removeTemplate(template);
|
||||
|
||||
+10
-48
@@ -22,62 +22,46 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.ui.SizedIcon;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RunConfigurationsComboBoxAction extends ComboBoxAction implements DumbAware {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.actions.RunConfigurationAction");
|
||||
private static final Key<ComboBoxButton> BUTTON_KEY = Key.create("COMBOBOX_BUTTON");
|
||||
|
||||
public static final Icon CHECKED_ICON = new SizedIcon(AllIcons.Actions.Checked, 16, 16);
|
||||
public static final Icon CHECKED_SELECTED_ICON = new SizedIcon(AllIcons.Actions.Checked_selected, 16, 16);
|
||||
public static final Icon EMPTY_ICON = EmptyIcon.ICON_16;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final IdeFrame ideFrame = findFrame(e.getData(PlatformDataKeys.CONTEXT_COMPONENT));
|
||||
final ComboBoxButton button = (ComboBoxButton)ideFrame.getComponent().getRootPane().getClientProperty(BUTTON_KEY);
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
ComboBoxButton button = (ComboBoxButton)e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
if (button == null || !button.isShowing()) return;
|
||||
button.showPopup();
|
||||
}
|
||||
|
||||
private static IdeFrame findFrame(final Component component) {
|
||||
return UIUtil.getParentOfType(IdeFrame.class, component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
ComboBoxButton button = (ComboBoxButton)presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
|
||||
presentation.setDescription(ExecutionBundle.message("choose.run.configuration.action.description"));
|
||||
presentation.setEnabled(findFrame(e.getData(PlatformDataKeys.CONTEXT_COMPONENT)) != null);
|
||||
presentation.setEnabled(button != null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (project == null || project.isDisposed() || !project.isInitialized()) {
|
||||
//if (ProjectManager.getInstance().getOpenProjects().length > 0) {
|
||||
// // do nothing if frame is not active
|
||||
// return;
|
||||
//}
|
||||
|
||||
updateButton(null, null, null, presentation);
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
@@ -135,31 +119,9 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
|
||||
@Override
|
||||
public JComponent createCustomComponent(final Presentation presentation) {
|
||||
final ComboBoxButton comboBoxButton = new ComboBoxButton(presentation) {
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify(); //To change body of overriden methods use Options | File Templates.;
|
||||
final IdeFrame frame = findFrame(this);
|
||||
LOG.assertTrue(frame != null);
|
||||
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
final IdeFrame frame = findFrame(this);
|
||||
LOG.assertTrue(frame != null);
|
||||
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, null);
|
||||
presentation.setIcon(null);
|
||||
setIcon(null);
|
||||
super.removeNotify();
|
||||
}
|
||||
};
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
|
||||
panel.add(comboBoxButton);
|
||||
panel.setOpaque(false);
|
||||
return panel;
|
||||
ComboBoxButton button = new ComboBoxButton(presentation);
|
||||
button.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.execution.ui.RunContentManagerImpl;
|
||||
import com.intellij.ide.SaveAndSyncHandler;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
@@ -45,7 +46,6 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -548,7 +548,8 @@ public class ExecutionManagerImpl extends ExecutionManager implements Disposable
|
||||
if (myProject.isDisposed()) return;
|
||||
|
||||
myProject.getMessageBus().syncPublisher(EXECUTION_TOPIC).processTerminated(myProfile, myProcessHandler);
|
||||
VirtualFileManager.getInstance().asyncRefresh(null);
|
||||
|
||||
SaveAndSyncHandler.getInstance().scheduleRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1055,8 +1055,6 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
|
||||
window.validate();
|
||||
window.repaint();
|
||||
table.revalidate();
|
||||
table.repaint();
|
||||
}
|
||||
|
||||
private static Rectangle fitToScreen(@NotNull Dimension newDim, @NotNull RelativePoint popupPosition, JTable table) {
|
||||
|
||||
@@ -267,7 +267,7 @@ class FindInProjectTask {
|
||||
|
||||
@NotNull
|
||||
private Collection<VirtualFile> collectFilesInScope(@NotNull final Set<VirtualFile> alreadySearched, final boolean skipIndexed) {
|
||||
SearchScope customScope = myFindModel.getCustomScope();
|
||||
SearchScope customScope = myFindModel.isCustomScope() ? myFindModel.getCustomScope() : null;
|
||||
final GlobalSearchScope globalCustomScope = toGlobal(customScope);
|
||||
|
||||
final ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(myProject);
|
||||
@@ -432,17 +432,7 @@ class FindInProjectTask {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
SearchScope customScope = myFindModel.getCustomScope();
|
||||
GlobalSearchScope scope = myPsiDirectory != null
|
||||
? GlobalSearchScopesCore.directoryScope(myPsiDirectory, myFindModel.isWithSubdirectories())
|
||||
: myModule != null
|
||||
? myModule.getModuleContentScope()
|
||||
: customScope instanceof GlobalSearchScope
|
||||
? (GlobalSearchScope)customScope
|
||||
: toGlobal(customScope);
|
||||
if (scope == null) {
|
||||
scope = ProjectScope.getContentScope(myProject);
|
||||
}
|
||||
GlobalSearchScope scope = toGlobal(FindInProjectUtil.getScopeFromModel(myProject, myFindModel));
|
||||
|
||||
final Set<VirtualFile> resultFiles = new LinkedHashSet<VirtualFile>();
|
||||
|
||||
|
||||
@@ -49,10 +49,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.ex.VirtualFileManagerEx;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopesCore;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewManager;
|
||||
@@ -443,7 +440,7 @@ public class FindInProjectUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
static SearchScope getScopeFromModel(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
SearchScope customScope = findModel.getCustomScope();
|
||||
PsiDirectory psiDir = getPsiDirectory(findModel, project);
|
||||
VirtualFile directory = psiDir == null ? null : psiDir.getVirtualFile();
|
||||
@@ -452,8 +449,8 @@ public class FindInProjectUtil {
|
||||
// we don't have to check for myProjectFileIndex.isExcluded(file) here like FindInProjectTask.collectFilesInScope() does
|
||||
// because all found usages are guaranteed to be not in excluded dir
|
||||
directory != null ? GlobalSearchScopesCore.directoryScope(project, directory, findModel.isWithSubdirectories()) :
|
||||
module != null ? GlobalSearchScope.moduleScope(module) :
|
||||
findModel.isProjectScope() ? GlobalSearchScope.projectScope(project) :
|
||||
module != null ? module.getModuleContentScope() :
|
||||
findModel.isProjectScope() ? ProjectScope.getContentScope(project) :
|
||||
GlobalSearchScope.allScope(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +308,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
|
||||
if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit())
|
||||
return;
|
||||
for (FindResult range : mySearchResults.getOccurrences()) {
|
||||
if (range.getEndOffset() > mySearchResults.getEditor().getDocument().getTextLength()) continue;
|
||||
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
|
||||
if (range.getLength() == 0) {
|
||||
attributes = attributes.clone();
|
||||
|
||||
@@ -99,8 +99,8 @@ public class TemplateKindCombo extends ComboboxWithBrowseButton {
|
||||
}
|
||||
|
||||
private void scrollBy(int delta) {
|
||||
if (delta == 0) return;
|
||||
final int size = getComboBox().getModel().getSize();
|
||||
if (delta == 0 || size == 0) return;
|
||||
int next = getComboBox().getSelectedIndex() + delta;
|
||||
if (next < 0 || next >= size) {
|
||||
if (!UISettings.getInstance().CYCLE_SCROLLING) {
|
||||
|
||||
@@ -29,7 +29,11 @@ public abstract class ScratchFileService {
|
||||
public enum Option { existing_only, create_if_missing, create_new_always }
|
||||
|
||||
public static ScratchFileService getInstance() {
|
||||
return ServiceManager.getService(ScratchFileService.class);
|
||||
return ServiceHolder.instance;
|
||||
}
|
||||
|
||||
private static class ServiceHolder {
|
||||
static final ScratchFileService instance = ServiceManager.getService(ScratchFileService.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-2
@@ -58,8 +58,7 @@ public class EnforcedPlainTextFileTypeManager implements ProjectManagerListener
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Project project : myPlainTextFileSets.keySet()) {
|
||||
Collection<VirtualFile> projectSet = myPlainTextFileSets.get(project);
|
||||
for (Collection<VirtualFile> projectSet : myPlainTextFileSets.values()) {
|
||||
if (projectSet != null && projectSet.contains(file)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class DetectedIndentOptionsNotificationProvider extends EditorNotificatio
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
|
||||
CommonCodeStyleSettings.IndentOptions userOptions = settings.getIndentOptions(psiFile.getFileType());
|
||||
CommonCodeStyleSettings.IndentOptions detectedOptions = CodeStyleSettingsManager.getSettings(project).getIndentOptionsByFile(
|
||||
psiFile, null, true,
|
||||
psiFile, null, false,
|
||||
new Processor<FileIndentOptionsProvider>() {
|
||||
@Override
|
||||
public boolean process(FileIndentOptionsProvider provider) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user