Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2014-02-04 11:34:58 +04:00
181 changed files with 2181 additions and 1382 deletions
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -268,7 +268,7 @@ public def layoutCommunityPlugins(String home) {
}
}
dir("properties") {
pluginDir("properties") {
dir("lib") {
jar("properties.jar") {
module("properties-psi-api")
@@ -46,10 +46,10 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
}
@Override
protected RunContentDescriptor doExecute(final Project project,
final RunProfileState state,
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
final ExecutionEnvironment env) throws ExecutionException {
@NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
return createContentDescriptor(project, state, contentToReuse, env);
}
@@ -15,7 +15,10 @@
*/
package com.intellij.execution.impl;
import com.intellij.execution.*;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.RunnerRegistry;
import com.intellij.execution.configurations.*;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.process.CapturingProcessAdapter;
@@ -66,10 +69,10 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
@Override
protected RunContentDescriptor doExecute(final Project project,
final RunProfileState state,
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
final ExecutionEnvironment env) throws ExecutionException {
@NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult;
@@ -112,7 +112,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
private final MultiMap<TemplatesGroup,ProjectTemplate> myTemplatesMap;
private boolean myRemoteTemplatesLoaded;
private Cards myCurrentCard;
private boolean myNeedDownload;
public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) {
myContext = context;
@@ -163,7 +162,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myConfigurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
if (myCurrentCard == Cards.FRAMEWORKS) {
if (isFrameworksMode()) {
myFrameworksPanel.addSupport(module, rootModel);
}
}
@@ -210,6 +209,10 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myTemplatesList.restoreSelection();
}
private boolean isFrameworksMode() {
return myCurrentCard == Cards.FRAMEWORKS && getSelectedBuilder().equals(myContext.getProjectBuilder());
}
private List<TemplatesGroup> fillTemplatesMap(WizardContext context) {
List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
@@ -306,7 +309,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
// new TemplatesGroup selected
public void projectTypeChanged() {
myNeedDownload = false;
TemplatesGroup group = getSelectedGroup();
if (group == null) return;
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
@@ -332,7 +334,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myFrameworksPanel.setProviders(providers);
}
getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);
myNeedDownload = true;
showCard(FRAMEWORKS_CARD);
}
@@ -412,7 +413,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
}
public void onWizardFinished() throws CommitStepException {
if (myNeedDownload) {
if (isFrameworksMode()) {
boolean ok = myFrameworksPanel.downloadLibraries();
if (!ok) {
int answer = Messages.showYesNoDialog(getComponent(),
@@ -579,7 +579,7 @@ public class AnnotationsHighlightUtil {
public static HighlightInfo checkFunctionalInterface(@NotNull PsiAnnotation annotation, @NotNull LanguageLevel languageLevel) {
final String errorMessage = LambdaUtil.checkFunctionalInterface(annotation, languageLevel);
if (errorMessage != null) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(annotation).descriptionAndTooltip(errorMessage).create();
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotation).descriptionAndTooltip(errorMessage).create();
}
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -50,7 +50,7 @@ public class ImplementMethodsFix extends LocalQuickFixAndIntentionActionOnPsiEle
@Override
@NotNull
public String getFamilyName() {
return QuickFixBundle.message("implement.methods.fix");
return getText();
}
@Override
@@ -113,6 +113,7 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
if (classes.length == 0) return Collections.emptyList();
List<PsiClass> classList = new ArrayList<PsiClass>(classes.length);
boolean isAnnotationReference = myElement.getParent() instanceof PsiAnnotation;
final PsiFile file = myElement.getContainingFile();
for (PsiClass aClass : classes) {
if (isAnnotationReference && !aClass.isAnnotationType()) continue;
if (JavaCompletionUtil.isInExcludedPackage(aClass, false)) continue;
@@ -120,7 +121,7 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
String qName = aClass.getQualifiedName();
if (qName != null) { //filter local classes
if (qName.indexOf('.') == -1) continue; //do not show classes from default package)
if (qName.endsWith(name) && ImportFilter.shouldImport(qName)) {
if (qName.endsWith(name) && ImportFilter.shouldImport(file, qName)) {
if (isAccessible(aClass, myElement)) {
classList.add(aClass);
}
@@ -370,7 +370,7 @@ public class ImportHelper{
String className = refClass.getQualifiedName();
if (className == null) return true;
if (!ImportFilter.shouldImport(className)) {
if (!ImportFilter.shouldImport(file, className)) {
return false;
}
String packageName = getPackageOrClassName(className);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -26,8 +26,6 @@ package com.intellij.refactoring.makeStatic;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -50,6 +48,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
public static final String REFACTORING_NAME = RefactoringBundle.message("make.method.static.title");
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.makeMethodStatic.MakeMethodStaticHandler");
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
@@ -71,6 +70,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
invoke(project, new PsiElement[]{element}, dataContext);
}
@Override
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
if(elements.length != 1 || !(elements[0] instanceof PsiTypeParameterListOwner)) return;
@@ -108,10 +108,7 @@ public class MakeStaticHandler implements RefactoringActionHandler {
@Override
public boolean process(PsiReference reference) {
final PsiElement element = reference.getElement();
if (element instanceof PsiMethodReferenceExpression) {
return false;
}
return true;
return !(element instanceof PsiMethodReferenceExpression);
}
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -107,6 +107,7 @@ public class InlineUtil {
builder.append(exprType.getCanonicalText());
builder.append("[]{");
builder.append(StringUtil.join(Arrays.asList(arguments), new Function<PsiExpression, String>() {
@Override
public String fun(final PsiExpression expr) {
return expr.getText();
}
@@ -294,8 +295,10 @@ public class InlineUtil {
public static boolean allUsagesAreTailCalls(final PsiMethod method) {
final List<PsiReference> nonTailCallUsages = Collections.synchronizedList(new ArrayList<PsiReference>());
boolean result = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ReferencesSearch.search(method).forEach(new Processor<PsiReference>() {
@Override
public boolean process(final PsiReference psiReference) {
ProgressManager.checkCanceled();
if (getTailCallType(psiReference) == TailCallType.None) {
@@ -1,7 +1,9 @@
package com.intellij.codeInsight;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Eugene.Kudelevsky
@@ -9,11 +11,11 @@ import org.jetbrains.annotations.NotNull;
public abstract class ImportFilter {
public static final ExtensionPointName<ImportFilter> EP_NAME = new ExtensionPointName<ImportFilter>("com.intellij.importFilter");
public abstract boolean shouldUseFullyQualifiedName(@NotNull String classQualifiedName);
public abstract boolean shouldUseFullyQualifiedName(@Nullable PsiFile targetFile, @NotNull String classQualifiedName);
public static boolean shouldImport(@NotNull String classQualifiedName) {
public static boolean shouldImport(@Nullable PsiFile targetFile, @NotNull String classQualifiedName) {
for (ImportFilter filter : EP_NAME.getExtensions()) {
if (filter.shouldUseFullyQualifiedName(classQualifiedName)) {
if (filter.shouldUseFullyQualifiedName(targetFile, classQualifiedName)) {
return false;
}
}
@@ -40,8 +40,6 @@ public class LambdaHighlightingUtil {
if (signatures == null) return interfaceNonFunctionalMessage;
if (signatures.isEmpty()) return "No target method found";
if (signatures.size() == 1) {
final MethodSignature functionalMethod = signatures.get(0);
if (functionalMethod.getTypeParameters().length > 0) return "Target method is generic";
return null;
}
return "Multiple non-overriding abstract methods found";
@@ -106,6 +104,12 @@ public class LambdaHighlightingUtil {
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(GenericsUtil.eliminateWildcards(functionalInterfaceType));
final PsiClass aClass = resolveResult.getElement();
if (aClass != null) {
if (aClass instanceof PsiTypeParameter) return null; //should be logged as cyclic inference
final List<MethodSignature> signatures = LambdaUtil.findFunctionCandidates(aClass);
if (signatures != null && signatures.size() == 1) {
final MethodSignature functionalMethod = signatures.get(0);
if (functionalMethod.getTypeParameters().length > 0) return "Target method is generic";
}
if (checkReturnTypeApplicable(resolveResult, aClass)) {
return "No instance of type " + functionalInterfaceType.getPresentableText() + " exists so that lambda expression can be type-checked";
}
@@ -250,7 +250,7 @@ public class LambdaUtil {
}
@Nullable
static List<MethodSignature> findFunctionCandidates(PsiClass psiClass) {
public static List<MethodSignature> findFunctionCandidates(PsiClass psiClass) {
if (psiClass instanceof PsiAnonymousClass) {
psiClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)psiClass).getBaseClassType());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -370,7 +370,7 @@ public class PsiImplUtil {
// todo[r.sh] cache?
@Nullable
public static Set<TargetType> getAnnotationTargets(PsiClass annotationType) {
public static Set<TargetType> getAnnotationTargets(@NotNull PsiClass annotationType) {
if (!annotationType.isAnnotationType()) return null;
PsiModifierList modifierList = annotationType.getModifierList();
if (modifierList == null) return null;
@@ -34,7 +34,6 @@ import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.ReflectionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -327,6 +326,13 @@ public class InferenceSession {
}
}
}
for (PsiClassType thrownType : method.getThrowsList().getReferencedTypes()) {
final InferenceVariable variable = getInferenceVariable(thrownType);
if (variable != null) {
variable.setThrows();
}
}
}
private InferenceVariable shouldResolveAndInstantiate(PsiType returnType, PsiType targetType) {
@@ -341,7 +347,8 @@ public class InferenceSession {
}
private static boolean hasPrimitiveWrapperBound(InferenceVariable inferenceVariable) {
for (InferenceBound inferenceBound : InferenceBound.values()) {
final InferenceBound[] boundTypes = {InferenceBound.UPPER, InferenceBound.LOWER};
for (InferenceBound inferenceBound : boundTypes) {
final List<PsiType> bounds = inferenceVariable.getBounds(inferenceBound);
for (PsiType bound : bounds) {
if (PsiPrimitiveType.getUnboxedType(bound) != null) {
@@ -593,7 +600,7 @@ public class InferenceSession {
else {
boolean inferred = false;
PsiType glb = null;
if (isThrowable(upperBounds)) {
if (inferenceVariable.isThrownBound() && isThrowable(upperBounds)) {
glb = PsiType.getJavaLangRuntimeException(myManager, GlobalSearchScope.allScope(myManager.getProject()));
inferred = true;
} else {
@@ -27,6 +27,7 @@ public class InferenceVariable {
return myParameter;
}
private boolean myThrownBound = false;
private final Map<InferenceBound, List<PsiType>> myBounds = new HashMap<InferenceBound, List<PsiType>>();
private final PsiTypeParameter myParameter;
@@ -47,6 +48,9 @@ public class InferenceVariable {
}
public boolean addBound(PsiType classType, InferenceBound inferenceBound) {
if (inferenceBound == InferenceBound.EQ && classType instanceof PsiClassType && ((PsiClassType)classType).resolve() == myParameter) {
return false;
}
List<PsiType> list = myBounds.get(inferenceBound);
if (list == null) {
list = new ArrayList<PsiType>();
@@ -74,4 +78,12 @@ public class InferenceVariable {
}
return dependencies;
}
public boolean isThrownBound() {
return myThrownBound;
}
public void setThrows() {
myThrownBound = true;
}
}
@@ -21,7 +21,6 @@ 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.impl.source.tree.java.PsiMethodReferenceExpressionImpl;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.Function;
@@ -74,11 +73,17 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
}
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, PsiUtil.resolveGenericsClassInType(myT));
for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) {
if (!session.isProperType(substitutor.substitute(parameter.getType()))) return false;
if (myExpression instanceof PsiLambdaExpression && !((PsiLambdaExpression)myExpression).hasFormalParameterTypes() ||
myExpression instanceof PsiMethodReferenceExpression && !((PsiMethodReferenceExpression)myExpression).isExact()) {
for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) {
if (!session.isProperType(substitutor.substitute(parameter.getType()))) return false;
}
}
final PsiType returnType = interfaceMethod.getReturnType();
if (!session.isProperType(substitutor.substitute(returnType))) return false;
if (myExpression instanceof PsiLambdaExpression || !((PsiMethodReferenceExpression)myExpression).isExact()) {
if (!session.isProperType(substitutor.substitute(returnType))) return false;
}
final List<PsiType>
expectedThrownTypes = ContainerUtil.map(interfaceMethod.getThrowsList().getReferencedTypes(), new Function<PsiType, PsiType>() {
@@ -133,10 +138,16 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
for (PsiType thrownType : thrownTypes) {
if (!isAddressed(expectedProperTypes, thrownType)) {
for (PsiType expectedNonProperThrownType : expectedNonProperThrownTypes) {
constraints.add(new TypeCompatibilityConstraint(expectedNonProperThrownType, thrownType));
constraints.add(new StrictSubtypingConstraint(expectedNonProperThrownType, thrownType));
}
}
}
for (PsiType expectedNonProperThrownType : expectedNonProperThrownTypes) {
final InferenceVariable variable = session.getInferenceVariable(expectedNonProperThrownType);
LOG.assertTrue(variable != null);
variable.setThrows();
}
}
}
@@ -28,10 +28,8 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
return false;
}
if (myExpression.hasFormalParameterTypes()) {
}
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(
FunctionalInterfaceParameterizationUtil.getGroundTargetType(myT, myExpression, false));
final PsiType groundTargetType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(myT, myExpression, false);
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(groundTargetType);
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
if (interfaceMethod == null) {
return false;
@@ -47,6 +45,7 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
for (int i = 0; i < lambdaParameters.length; i++) {
constraints.add(new TypeEqualityConstraint(lambdaParameters[i].getType(), substitutor.substitute(parameters[i].getType())));
}
constraints.add(new StrictSubtypingConstraint(myT, groundTargetType));
} else {
for (PsiParameter parameter : parameters) {
if (!session.isProperType(substitutor.substitute(parameter.getType()))) {
@@ -55,7 +54,7 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
}
}
final PsiType returnType = interfaceMethod.getReturnType();
PsiType returnType = interfaceMethod.getReturnType();
if (returnType != null) {
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions(myExpression);
if (returnType.equals(PsiType.VOID)) {
@@ -66,8 +65,11 @@ public class LambdaExpressionCompatibilityConstraint implements ConstraintFormul
if (returnExpressions.isEmpty() && !myExpression.isValueCompatible()) { //not value-compatible
return false;
}
for (PsiExpression returnExpression : returnExpressions) {
constraints.add(new ExpressionCompatibilityConstraint(returnExpression, GenericsUtil.eliminateWildcards(substitutor.substitute(returnType))));
returnType = substitutor.substitute(returnType);
if (!session.isProperType(returnType)) {
for (PsiExpression returnExpression : returnExpressions) {
constraints.add(new ExpressionCompatibilityConstraint(returnExpression, GenericsUtil.eliminateWildcards(returnType)));
}
}
}
}
@@ -713,7 +713,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
ProgressManager.checkCanceled();
LOG.assertTrue(typeParameter != null);
if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) {
substitutor = substitutor.put(typeParameter, TypeConversionUtil.erasure(siteSubstitutor.substitute(typeParameter), substitutor));
PsiType type = siteSubstitutor.substitute(typeParameter);
if (type instanceof PsiClassType && ((PsiClassType)type).resolve() instanceof PsiTypeParameter) {
type = TypeConversionUtil.erasure(type, substitutor);
}
substitutor = substitutor.put(typeParameter, type);
}
}
return substitutor;
@@ -0,0 +1,23 @@
import java.util.Collection;
import java.util.List;
class Idea {
class Library<T> {
public void f(Base<T> x) {
}
public void f(Derived<T> x) {
}
}
class Wrapper<T> {
}
class Base<In> {
}
class Derived<In> extends Base<In> {
}
public void main(Derived<Wrapper<String>> x) {
new Library<Wrapper<String>>().f(x);
}
}
@@ -0,0 +1,13 @@
import java.util.List;
public class Sample {
interface Fun<A extends List <String>, B> {
B f(A a);
}
<T, R> void foo(Fun<? super T , R> f) {}
{
foo((List<String> ls) -> ls.size());
}
}
@@ -1,4 +1,4 @@
<warning descr="Multiple non-overriding abstract methods found">@FunctionalInterface</warning>
<error descr="Multiple non-overriding abstract methods found">@FunctionalInterface</error>
interface Test {
void foo();
void bar();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ import java.io.File;
import java.util.Collection;
/**
* This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run.
* This class intended for "heavy-loaded" tests only, e.g. those need to setup separate project directory structure to run.
* For "lightweight" tests use LightAdvHighlightingTest.
*/
public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
@@ -336,6 +336,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA118037() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA119546() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA118527() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
@@ -50,6 +50,10 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
doTest(false);
}
public void testLambdaGroundTest() throws Exception {
doTest(false);
}
private void doTest(final boolean checkWarnings) {
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
@@ -31,7 +31,7 @@ public class FunctionalInterfaceTest extends LightDaemonAnalyzerTestCase {
final PsiClass psiClass = getJavaFacade().findClass("Foo", GlobalSearchScope.projectScope(getProject()));
assertNotNull("Class Foo not found", psiClass);
final String errorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(psiClass);
final String errorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(getJavaFacade().getElementFactory().createType(psiClass));
assertEquals(expectedErrorMessage, errorMessage);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -189,7 +189,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
return findActionWithText(getAvailableActions(), text);
}
public static IntentionAction findActionWithText(final List<IntentionAction> actions, final String text) {
public static IntentionAction findActionWithText(@NotNull List<IntentionAction> actions, final String text) {
for (IntentionAction action : actions) {
if (text.equals(action.getText())) {
return action;
+116 -83
View File
@@ -17,7 +17,7 @@
#include "stdafx.h"
#include "WinLauncher.h"
typedef JNIIMPORT jint (JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args);
typedef JNIIMPORT jint(JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args);
HINSTANCE hInst; // current instance
char jvmPath[_MAX_PATH];
@@ -45,7 +45,7 @@ std::string LoadStdString(int id)
{
wchar_t *buf = NULL;
int len = LoadStringW(hInst, id, reinterpret_cast<LPWSTR>(&buf), 0);
if (len)
if (len)
{
int cbANSI = WideCharToMultiByte(CP_ACP, 0, buf, len, NULL, 0, NULL, NULL);
char* ansiBuf = new char[cbANSI];
@@ -65,7 +65,7 @@ bool FileExists(const std::string& path)
bool IsValidJRE(const char* path)
{
std::string dllPath(path);
if (dllPath[dllPath.size()-1] != '\\')
if (dllPath[dllPath.size() - 1] != '\\')
{
dllPath += "\\";
}
@@ -83,16 +83,16 @@ bool FindValidJVM(const char* path)
{
if (IsValidJRE(path))
{
strcpy_s(jvmPath, _MAX_PATH-1, path);
strcpy_s(jvmPath, _MAX_PATH - 1, path);
return true;
}
char jrePath[_MAX_PATH];
strcpy_s(jrePath, path);
if (jrePath[strlen(jrePath)-1] != '\\')
if (jrePath[strlen(jrePath) - 1] != '\\')
{
strcat_s(jrePath, "\\");
}
strcat_s(jrePath, _MAX_PATH-1, "jre");
strcat_s(jrePath, _MAX_PATH - 1, "jre");
if (IsValidJRE(jrePath))
{
strcpy_s(jvmPath, jrePath);
@@ -104,13 +104,13 @@ bool FindValidJVM(const char* path)
std::string GetAdjacentDir(const char* suffix)
{
char libDir[_MAX_PATH];
GetModuleFileNameA(NULL, libDir, _MAX_PATH-1);
GetModuleFileNameA(NULL, libDir, _MAX_PATH - 1);
char* lastSlash = strrchr(libDir, '\\');
if (!lastSlash) return "";
*lastSlash = '\0';
lastSlash = strrchr(libDir, '\\');
if (!lastSlash) return "";
strcpy(lastSlash+1, suffix);
strcpy(lastSlash + 1, suffix);
strcat_s(libDir, "\\");
return std::string(libDir);
}
@@ -118,7 +118,7 @@ std::string GetAdjacentDir(const char* suffix)
bool FindJVMInEnvVar(const char* envVarName, bool& result)
{
char envVarValue[_MAX_PATH];
if (GetEnvironmentVariableA(envVarName, envVarValue, _MAX_PATH-1))
if (GetEnvironmentVariableA(envVarName, envVarValue, _MAX_PATH - 1))
{
if (FindValidJVM(envVarValue))
{
@@ -145,9 +145,9 @@ bool FindJVMInRegistryKey(const char* key, bool wow64_32)
if (wow64_32) flags |= KEY_WOW64_32KEY;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return false;
char javaHome[_MAX_PATH];
DWORD javaHomeSize = _MAX_PATH-1;
DWORD javaHomeSize = _MAX_PATH - 1;
bool success = false;
if (RegQueryValueExA(hKey, "JavaHome", NULL, NULL, (LPBYTE) javaHome, &javaHomeSize) == ERROR_SUCCESS)
if (RegQueryValueExA(hKey, "JavaHome", NULL, NULL, (LPBYTE)javaHome, &javaHomeSize) == ERROR_SUCCESS)
{
success = FindValidJVM(javaHome);
}
@@ -157,7 +157,7 @@ bool FindJVMInRegistryKey(const char* key, bool wow64_32)
bool FindJVMInRegistryWithVersion(const char* version, bool wow64_32)
{
const char* keyName = LoadStdString(IDS_JDK_ONLY) == std::string("true")
const char* keyName = LoadStdString(IDS_JDK_ONLY) == std::string("true")
? "Java Development Kit"
: "Java Runtime Environment";
@@ -217,7 +217,7 @@ void TrimLine(char* line)
{
*p-- = '\0';
}
while(p >= line && (*p == ' ' || *p == '\t'))
while (p >= line && (*p == ' ' || *p == '\t'))
{
*p-- = '\0';
}
@@ -227,9 +227,9 @@ bool LoadVMOptionsFile(const TCHAR* path, std::vector<std::string>& vmOptionLine
{
FILE *f = _tfopen(path, _T("rt"));
if (!f) return false;
char line[_MAX_PATH];
while(fgets(line, _MAX_PATH-1, f))
while (fgets(line, _MAX_PATH - 1, f))
{
TrimLine(line);
if (line[0] == '#') continue;
@@ -253,7 +253,7 @@ std::string FindToolsJar()
size_t lastSlash = toolsJarPath.rfind('\\');
if (lastSlash != std::string::npos)
{
toolsJarPath = toolsJarPath.substr(0, lastSlash+1) + "lib\\tools.jar";
toolsJarPath = toolsJarPath.substr(0, lastSlash + 1) + "lib\\tools.jar";
if (FileExists(toolsJarPath))
{
return toolsJarPath;
@@ -272,7 +272,7 @@ std::string CollectLibJars(const std::string& jarList)
std::string result;
int pos = 0;
while(pos < jarList.size())
while (pos < jarList.size())
{
int delimiterPos = jarList.find(';', pos);
if (delimiterPos == std::string::npos)
@@ -284,8 +284,8 @@ std::string CollectLibJars(const std::string& jarList)
result += ";";
}
result += libDir;
result += jarList.substr(pos, delimiterPos-pos);
pos = delimiterPos+1;
result += jarList.substr(pos, delimiterPos - pos);
pos = delimiterPos + 1;
}
return result;
}
@@ -324,17 +324,17 @@ bool AddClassPathOptions(std::vector<std::string>& vmOptionLines)
void AddPredefinedVMOptions(std::vector<std::string>& vmOptionLines)
{
std::string vmOptions = LoadStdString(IDS_VM_OPTIONS);
while(vmOptions.size() > 0)
while (vmOptions.size() > 0)
{
int pos = vmOptions.find(' ');
if (pos == std::string::npos) pos = vmOptions.size();
vmOptionLines.push_back(vmOptions.substr(0, pos));
while(pos < vmOptions.size() && vmOptions[pos] == ' ') pos++;
while (pos < vmOptions.size() && vmOptions[pos] == ' ') pos++;
vmOptions = vmOptions.substr(pos);
}
char ideaProperties[_MAX_PATH];
if (GetEnvironmentVariableA("IDEA_PROPERTIES", ideaProperties, _MAX_PATH-1))
if (GetEnvironmentVariableA("IDEA_PROPERTIES", ideaProperties, _MAX_PATH - 1))
{
vmOptionLines.push_back(std::string("-Didea.properties.file=") + ideaProperties);
}
@@ -343,17 +343,17 @@ void AddPredefinedVMOptions(std::vector<std::string>& vmOptionLines)
bool LoadVMOptions()
{
TCHAR optionsFileName[_MAX_PATH];
if (LoadString(hInst, IDS_VM_OPTIONS_PATH, optionsFileName, _MAX_PATH-1))
if (LoadString(hInst, IDS_VM_OPTIONS_PATH, optionsFileName, _MAX_PATH - 1))
{
TCHAR fullOptionsFileName[_MAX_PATH];
ExpandEnvironmentStrings(optionsFileName, fullOptionsFileName, _MAX_PATH-1);
ExpandEnvironmentStrings(optionsFileName, fullOptionsFileName, _MAX_PATH - 1);
if (GetFileAttributes(fullOptionsFileName) == INVALID_FILE_ATTRIBUTES)
{
GetModuleFileName(NULL, fullOptionsFileName, _MAX_PATH-1);
GetModuleFileName(NULL, fullOptionsFileName, _MAX_PATH - 1);
_tcscat_s(fullOptionsFileName, _T(".vmoptions"));
}
std::vector<std::string> vmOptionLines;
if (LoadVMOptionsFile(fullOptionsFileName, vmOptionLines))
{
@@ -361,8 +361,8 @@ bool LoadVMOptions()
AddPredefinedVMOptions(vmOptionLines);
vmOptionCount = vmOptionLines.size();
vmOptions = (JavaVMOption*) malloc(vmOptionCount * sizeof(JavaVMOption));
for(int i=0; i<vmOptionLines.size(); i++)
vmOptions = (JavaVMOption*)malloc(vmOptionCount * sizeof(JavaVMOption));
for (int i = 0; i < vmOptionLines.size(); i++)
{
vmOptions[i].optionString = _strdup(vmOptionLines[i].c_str());
vmOptions[i].extraInfo = 0;
@@ -394,7 +394,7 @@ bool LoadJVMLibrary()
hJVM = LoadLibraryA(dllName.c_str());
if (hJVM)
{
pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM");
pCreateJavaVM = (JNI_createJavaVM)GetProcAddress(hJVM, "JNI_CreateJavaVM");
}
if (!pCreateJavaVM)
{
@@ -416,7 +416,7 @@ bool CreateJVM()
int result = pCreateJavaVM(&jvm, &env, &initArgs);
for(int i=0; i<vmOptionCount; i++)
for (int i = 0; i < vmOptionCount; i++)
{
free(vmOptions[i].optionString);
}
@@ -438,11 +438,11 @@ jobjectArray PrepareCommandLine()
int numArgs;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
jclass stringClass = env->FindClass("java/lang/String");
jobjectArray args = env->NewObjectArray(numArgs-1, stringClass, NULL);
for(int i=1; i<numArgs; i++)
jobjectArray args = env->NewObjectArray(numArgs - 1, stringClass, NULL);
for (int i = 1; i < numArgs; i++)
{
const wchar_t* arg = argv[i];
env->SetObjectArrayElement(args, i-1, env->NewString((const jchar *) arg, wcslen(argv[i])));
env->SetObjectArrayElement(args, i - 1, env->NewString((const jchar *)arg, wcslen(argv[i])));
}
return args;
}
@@ -484,7 +484,7 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
attachArgs.version = JNI_VERSION_1_2;
attachArgs.name = "WinLauncher external command processing thread";
attachArgs.group = NULL;
jvm->AttachCurrentThread((void**) &env, &attachArgs);
jvm->AttachCurrentThread((void**)&env, &attachArgs);
std::string processorClassName = LoadStdString(IDS_COMMAND_LINE_PROCESSOR_CLASS);
jclass processorClass = env->FindClass(processorClassName.c_str());
@@ -493,8 +493,8 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
jmethodID processMethodID = env->GetStaticMethodID(processorClass, "processWindowsLauncherCommandLine", "(Ljava/lang/String;Ljava/lang/String;)V");
if (processMethodID)
{
jstring jCurDir = env->NewString((const jchar *) curDir.c_str(), curDir.size());
jstring jArgs = env->NewString((const jchar *) args.c_str(), args.size());
jstring jCurDir = env->NewString((const jchar *)curDir.c_str(), curDir.size());
jstring jArgs = env->NewString((const jchar *)args.c_str(), args.size());
env->CallStaticVoidMethod(processorClass, processMethodID, jCurDir, jArgs);
jthrowable exc = env->ExceptionOccurred();
if (exc)
@@ -509,7 +509,7 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
DWORD WINAPI SingleInstanceThread(LPVOID args)
{
while(true)
while (true)
{
WaitForSingleObject(hEvent, INFINITE);
if (terminating) break;
@@ -521,7 +521,7 @@ DWORD WINAPI SingleInstanceThread(LPVOID args)
if (pos >= 0)
{
std::wstring curDir = command.substr(0, pos);
std::wstring args = command.substr(pos+1);
std::wstring args = command.substr(pos + 1);
CallCommandLineProcessor(curDir, args);
}
@@ -534,7 +534,7 @@ DWORD WINAPI SingleInstanceThread(LPVOID args)
void SendCommandLineToFirstInstance()
{
wchar_t curDir[_MAX_PATH];
GetCurrentDirectoryW(_MAX_PATH-1, curDir);
GetCurrentDirectoryW(_MAX_PATH - 1, curDir);
std::wstring command(curDir);
command += _T("\n");
command += GetCommandLineW();
@@ -542,17 +542,17 @@ void SendCommandLineToFirstInstance()
void *view = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (view)
{
memcpy(view, command.c_str(), (command.size()+1) * sizeof(wchar_t));
memcpy(view, command.c_str(), (command.size() + 1) * sizeof(wchar_t));
UnmapViewOfFile(view);
}
SetEvent(hEvent);
SetEvent(hEvent);
}
bool CheckSingleInstance()
{
char moduleFileName[_MAX_PATH];
GetModuleFileNameA(NULL, moduleFileName, _MAX_PATH-1);
for(char *p = moduleFileName; *p; p++)
GetModuleFileNameA(NULL, moduleFileName, _MAX_PATH - 1);
for (char *p = moduleFileName; *p; p++)
{
if (*p == ':' || *p == '\\') *p = '_';
}
@@ -564,7 +564,7 @@ bool CheckSingleInstance()
hFileMapping = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, mappingName.c_str());
if (!hFileMapping)
{
hFileMapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, FILE_MAPPING_SIZE,
hFileMapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, FILE_MAPPING_SIZE,
mappingName.c_str());
return true;
}
@@ -579,11 +579,11 @@ bool CheckSingleInstance()
void DrawSplashImage(HWND hWnd)
{
HBITMAP hSplashBitmap = (HBITMAP) GetWindowLongPtr(hWnd, GWLP_USERDATA);
HBITMAP hSplashBitmap = (HBITMAP)GetWindowLongPtr(hWnd, GWLP_USERDATA);
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
HDC hMemDC = CreateCompatibleDC(hDC);
HBITMAP hOldBmp = (HBITMAP) SelectObject(hMemDC, hSplashBitmap);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDC, hSplashBitmap);
BITMAP splashBitmap;
GetObject(hSplashBitmap, sizeof(splashBitmap), &splashBitmap);
BitBlt(hDC, 0, 0, splashBitmap.bmWidth, splashBitmap.bmHeight, hMemDC, 0, 0, SRCCOPY);
@@ -594,12 +594,12 @@ void DrawSplashImage(HWND hWnd)
LRESULT CALLBACK SplashScreenWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
switch (uMsg)
{
case WM_PAINT:
DrawSplashImage(hWnd);
break;
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@@ -616,7 +616,7 @@ void RegisterSplashScreenWndClass()
wcx.hInstance = hInst;
wcx.hIcon = 0;
wcx.hCursor = LoadCursor(NULL, IDC_WAIT);
wcx.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
wcx.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcx.lpszMenuName = 0;
wcx.lpszClassName = splashClassName;
wcx.hIconSm = 0;
@@ -632,86 +632,120 @@ HWND ShowSplashScreenWindow(HBITMAP hSplashBitmap)
GetObject(hSplashBitmap, sizeof(splashBitmap), &splashBitmap);
int x = workArea.left + ((workArea.right - workArea.left) - splashBitmap.bmWidth) / 2;
int y = workArea.top + ((workArea.bottom - workArea.top) - splashBitmap.bmHeight) / 2;
HWND splashWindow = CreateWindowEx(WS_EX_TOOLWINDOW, splashClassName, splashClassName, WS_POPUP,
x, y, splashBitmap.bmWidth, splashBitmap.bmHeight, NULL, NULL, NULL, NULL);
SetWindowLongPtr(splashWindow, GWLP_USERDATA, (LONG_PTR) hSplashBitmap);
SetWindowLongPtr(splashWindow, GWLP_USERDATA, (LONG_PTR)hSplashBitmap);
ShowWindow(splashWindow, SW_SHOW);
UpdateWindow(splashWindow);
return splashWindow;
}
DWORD parentProcId;
HANDLE parentProcHandle;
BOOL IsParentProcessRunning(HANDLE hProcess)
{
if (hProcess == NULL) return FALSE;
DWORD ret = WaitForSingleObject(hProcess, 0);
return ret == WAIT_TIMEOUT;
}
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
static DWORD currentProcId = GetCurrentProcessId();
DWORD procId = 0;
GetWindowThreadProcessId(hWnd, &procId);
if(currentProcId == procId)
if (parentProcId == procId)
{
TCHAR className[_MAX_PATH];
GetClassName(hWnd, className, _MAX_PATH-1);
if (_tcscmp(className, splashClassName) != 0)
WINDOWINFO wi;
wi.cbSize = sizeof(WINDOWINFO);
GetWindowInfo(hWnd, &wi);
if ((wi.dwStyle & WS_VISIBLE) != 0)
{
WINDOWINFO wi;
wi.cbSize = sizeof(WINDOWINFO);
GetWindowInfo(hWnd, &wi);
if((wi.dwStyle & WS_VISIBLE) != 0)
{
HWND *phNewWindow = (HWND *) lParam;
*phNewWindow = hWnd;
return FALSE;
}
HWND *phNewWindow = (HWND *)lParam;
*phNewWindow = hWnd;
return FALSE;
}
}
return TRUE;
}
DWORD WINAPI SplashScreenThread(LPVOID args)
DWORD WINAPI SplashScreen(HBITMAP hSplashBitmap)
{
HBITMAP hSplashBitmap = static_cast<HBITMAP>(args);
RegisterSplashScreenWndClass();
HWND splashWindow = ShowSplashScreenWindow(hSplashBitmap);
MSG msg;
while(true)
while (true)
{
while (PeekMessage(&msg, splashWindow, 0, 0, PM_REMOVE))
while (PeekMessage(&msg, splashWindow, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(50);
HWND hNewWindow = NULL;
EnumWindows(EnumWindowsProc, (LPARAM) &hNewWindow);
EnumWindows(EnumWindowsProc, (LPARAM)&hNewWindow);
if (hNewWindow)
{
BringWindowToTop(hNewWindow);
Sleep(100);
DeleteObject(hSplashBitmap);
DestroyWindow(splashWindow);
break;
}
if (!IsParentProcessRunning(parentProcHandle)) break;
}
return 0;
}
void StartSplashProcess()
{
TCHAR ownPath[_MAX_PATH];
TCHAR params[_MAX_PATH];
PROCESS_INFORMATION splashProcessInformation;
STARTUPINFO startupInfo;
memset(&splashProcessInformation, 0, sizeof(splashProcessInformation));
memset(&startupInfo, 0, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.wShowWindow = SW_SHOW;
GetModuleFileName(NULL, ownPath, (sizeof(ownPath)));
_snwprintf(params, _MAX_PATH, _T("SPLASH %d"), GetCurrentProcessId());
if (CreateProcess(ownPath, params, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &splashProcessInformation))
{
CloseHandle(splashProcessInformation.hProcess);
CloseHandle(splashProcessInformation.hThread);
}
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
hInst = hInstance;
if (!CheckSingleInstance()) return 1;
HANDLE hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0));
if (hSplashBitmap)
if (__argc == 2 && _wcsicmp(__wargv[0], _T("SPLASH")) == 0)
{
CreateThread(NULL, 0, SplashScreenThread, hSplashBitmap, 0, NULL);
HBITMAP hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0));
if (hSplashBitmap)
{
parentProcId = _wtoi(__wargv[1]);
parentProcHandle = OpenProcess(SYNCHRONIZE, FALSE, parentProcId);
if (IsParentProcessRunning(parentProcHandle)) SplashScreen(hSplashBitmap);
}
CloseHandle(parentProcHandle);
return 0;
}
if (!CheckSingleInstance()) return 1;
if (wcsstr(lpCmdLine, _T("nosplash")) == NULL) StartSplashProcess();
if (!LocateJVM()) return 1;
if (!LoadVMOptions()) return 1;
if (!LoadJVMLibrary()) return 1;
@@ -731,4 +765,3 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
return 0;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl;
@@ -19,7 +34,7 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
private final ProblemsHolder myHolder;
private final ExternalAnnotator myAnnotator;
private boolean myOnTheFly;
private final boolean myOnTheFly;
public ExternalAnnotatorInspectionVisitor(ProblemsHolder holder, ExternalAnnotator annotator, boolean onTheFly) {
myHolder = holder;
@@ -27,17 +42,19 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
myOnTheFly = onTheFly;
}
public static ProblemDescriptor[] checkFileWithExternalAnnotator(PsiFile file,
InspectionManager manager,
boolean isOnTheFly, ExternalAnnotator annotator) {
@NotNull
public static <Init,Result> ProblemDescriptor[] checkFileWithExternalAnnotator(@NotNull PsiFile file,
@NotNull InspectionManager manager,
boolean isOnTheFly,
@NotNull ExternalAnnotator<Init,Result> annotator) {
if (isOnTheFly) {
// concrete JSLinterExternalAnnotator implementation does this work
return ProblemDescriptor.EMPTY_ARRAY;
}
Object info = annotator.collectInformation(file);
Init info = annotator.collectInformation(file);
if (info != null) {
Object annotationResult = annotator.doAnnotate(info);
Result annotationResult = annotator.doAnnotate(info);
if (annotationResult == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
@@ -48,10 +65,11 @@ public class ExternalAnnotatorInspectionVisitor extends PsiElementVisitor {
return ProblemDescriptor.EMPTY_ARRAY;
}
@NotNull
private static ProblemDescriptor[] convertToProblemDescriptors(@NotNull final List<Annotation> annotations,
@NotNull final InspectionManager manager,
@NotNull final PsiFile file) {
if (annotations.size() == 0) {
if (annotations.isEmpty()) {
return ProblemDescriptor.EMPTY_ARRAY;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -102,6 +102,7 @@ public class ProblemDescriptorBase extends CommonProblemDescriptorImpl implement
return PsiTreeUtil.findCommonParent(startElement, endElement);
}
@Override
@Nullable
public TextRange getTextRangeInElement() {
return myTextRangeInElement;
@@ -153,7 +153,7 @@ public class Main {
System.getProperty("java.home") + "/bin/java",
"-Xmx500m",
"-classpath",
copyPatchFile.getPath() + File.pathSeparator + copyPatchFile.getPath() + "/lib/log4j.jar",
copyPatchFile.getPath() + File.pathSeparator + PathManager.getLibPath() + "/log4j.jar",
"-Djava.io.tmpdir=" + tempDir,
"com.intellij.updater.Runner",
"install",
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -63,4 +63,7 @@ public abstract class ModalityState {
}
public abstract boolean dominates(@NotNull ModalityState anotherState);
@Override
public abstract String toString();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -58,11 +58,13 @@ public abstract class ObjectPattern<T, Self extends ObjectPattern<T, Self>> impl
}
public Self andNot(final ElementPattern pattern) {
return and(StandardPatterns.not(pattern));
ElementPattern<T> not = StandardPatterns.not(pattern);
return and(not);
}
public Self andOr(final ElementPattern... patterns) {
return and(StandardPatterns.or(patterns));
public Self andOr(@NotNull ElementPattern... patterns) {
ElementPattern or = StandardPatterns.or(patterns);
return and(or);
}
public Self and(final ElementPattern pattern) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -195,6 +195,11 @@ public class MockApplication extends MockComponentManager implements Application
public boolean dominates(@NotNull ModalityState anotherState) {
return false;
}
@Override
public String toString() {
return "NONE";
}
};
}
return MODALITY_STATE_NONE;
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.event.EditorMouseMotionListener;
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.UserDataHolder;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,10 +48,10 @@ public class ExternalSystemTaskRunner extends GenericProgramRunner {
@Nullable
@Override
protected RunContentDescriptor doExecute(Project project,
RunProfileState state,
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
RunContentDescriptor contentToReuse,
ExecutionEnvironment env) throws ExecutionException
@NotNull ExecutionEnvironment env) throws ExecutionException
{
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) return null;
@@ -26,9 +26,9 @@ import org.jetbrains.annotations.NotNull;
* @author Denis Zhdanov
* @since 4/25/11 1:16 PM
*/
public interface ConsoleActionsPostProcessor {
public abstract class ConsoleActionsPostProcessor {
ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
public static final ExtensionPointName<ConsoleActionsPostProcessor> EP_NAME = ExtensionPointName.create("com.intellij.consoleActionsPostProcessor");
/**
* Allows to adjust actions to use within the given console instance.
@@ -40,5 +40,12 @@ public interface ConsoleActionsPostProcessor {
* @return actions to use within the given console instance (given actions may be returned by default)
*/
@NotNull
AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions);
public AnAction[] postProcess(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
@NotNull
public AnAction[] postProcessPopupActions(@NotNull ConsoleView console, @NotNull AnAction[] actions) {
return actions;
}
}
@@ -33,7 +33,8 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> impl
@Deprecated
public static final DataKey<RunContentDescriptor> CONTENT_TO_REUSE_DATA_KEY = DataKey.create("contentToReuse");
@Deprecated @NonNls public static final String CONTENT_TO_REUSE = CONTENT_TO_REUSE_DATA_KEY.getName();
@SuppressWarnings({"UnusedDeclaration", "deprecation"}) @Deprecated @NonNls
public static final String CONTENT_TO_REUSE = CONTENT_TO_REUSE_DATA_KEY.getName();
@Override
@Nullable
@@ -53,4 +53,9 @@ public abstract class AbstractModuleBuilder extends ProjectBuilder {
public abstract void setModuleFilePath(@NonNls String path);
public abstract void setContentEntryPath(String moduleRootPath);
@Override
public boolean equals(Object obj) {
return obj instanceof AbstractModuleBuilder && getBuilderId() != null && getBuilderId().equals(((AbstractModuleBuilder)obj).getBuilderId());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -107,9 +107,11 @@ public class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable
application.invokeLater(new Runnable() {
@Override
public void run() {
EditorMarkupModel markupModel = (EditorMarkupModel)editor.getMarkupModel();
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
if (!editor.isDisposed()) {
EditorMarkupModel markupModel = (EditorMarkupModel)editor.getMarkupModel();
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
}
}
}, ModalityState.stateForComponent(editor.getComponent()), myProject.getDisposed());
}
@@ -279,7 +279,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
public void run() {
final Project project = myFile.getProject();
VirtualFile file = myFile.getVirtualFile();
assert file != null;
assert file != null: "Virtual file is null for " + file;
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
final Editor editor = FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
@@ -922,7 +922,21 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
if (group == null) {
group = (ActionGroup)actionManager.getAction(CONSOLE_VIEW_POPUP_MENU);
}
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
final ConsoleActionsPostProcessor[] postProcessors = Extensions.getExtensions(ConsoleActionsPostProcessor.EP_NAME);
AnAction[] result = group.getChildren(null);
for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
result = postProcessor.postProcessPopupActions(this, result);
}
final AnAction[] processedActions = result;
final ActionGroup processedGroup = new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return processedActions;
}
};
final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, processedGroup);
menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}
@@ -22,6 +22,7 @@ import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
* @author spleaner
@@ -29,10 +30,10 @@ import com.intellij.openapi.project.Project;
public abstract class DefaultProgramRunner extends GenericProgramRunner {
@Override
protected RunContentDescriptor doExecute(final Project project,
final RunProfileState state,
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
final ExecutionEnvironment env) throws ExecutionException {
@NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) return null;
@@ -84,23 +84,28 @@ public class NewElementAction extends AnAction implements DumbAware, PopupActio
@Override
public void update(AnActionEvent e){
final Presentation presentation = e.getPresentation();
final DataContext context = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(context);
Presentation presentation = e.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) {
presentation.setEnabled(false);
return;
}
if (Boolean.TRUE.equals(LangDataKeys.NO_NEW_ACTION.getData(context))) {
presentation.setEnabled(false);
return;
}
if (PlatformDataKeys.FILE_EDITOR.getData(context) != null) {
if (!isEnabled(e)) {
presentation.setEnabled(false);
return;
}
presentation.setEnabled(!ActionGroupUtil.isGroupEmpty(getGroup(context), e));
presentation.setEnabled(!ActionGroupUtil.isGroupEmpty(getGroup(e.getDataContext()), e));
}
protected boolean isEnabled(AnActionEvent e) {
if (Boolean.TRUE.equals(LangDataKeys.NO_NEW_ACTION.getData(e.getDataContext()))) {
return false;
}
if (PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext()) != null) {
return false;
}
return true;
}
protected ActionGroup getGroup(DataContext dataContext) {
@@ -17,10 +17,17 @@
package com.intellij.ide.actions;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
public class NewElementSamePlaceAction extends NewElementAction {
@Override
protected String getPopupTitle() {
return IdeBundle.message("title.popup.new.element.same.place");
}
@Override
protected boolean isEnabled(AnActionEvent e) {
return LangDataKeys.IDE_VIEW.getData(e.getDataContext()) != null;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl;
import com.intellij.util.FileContentUtil;
import com.intellij.util.FileContentUtilCore;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -8,6 +8,7 @@ import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.DoubleClickListener;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.table.JBTable;
@@ -444,7 +445,7 @@ public class InstalledPackagesPanel extends JPanel {
final int finalIndex = i;
final InstalledPackage pkg = getInstalledPackageAt(finalIndex);
restPackageCount.incrementAndGet();
serviceEx.fetchLatestVersion(pkg.getName(), new CatchingConsumer<String, Exception>() {
serviceEx.fetchLatestVersion(pkg, new CatchingConsumer<String, Exception>() {
private void decrement() {
if (restPackageCount.decrementAndGet() == 0) {
@@ -535,8 +536,10 @@ public class InstalledPackagesPanel extends JPanel {
final JLabel cell = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
final String version = (String)table.getValueAt(row, 1);
final String availableVersion = (String)table.getValueAt(row, 2);
cell.setIcon(PackageVersionComparator.VERSION_COMPARATOR.compare(version, availableVersion) < 0 && column == 2 ?
AllIcons.Vcs.Arrow_right : null);
boolean update = column == 2 &&
StringUtil.isNotEmpty(availableVersion) &&
PackageVersionComparator.VERSION_COMPARATOR.compare(version, availableVersion) < 0;
cell.setIcon(update ? AllIcons.Vcs.Arrow_right : null);
final Object pyPackage = table.getValueAt(row, 0);
if (pyPackage instanceof InstalledPackage) {
cell.setToolTipText(((InstalledPackage) pyPackage).getTooltipText());
@@ -15,6 +15,6 @@ public abstract class PackageManagementServiceEx extends PackageManagementServic
public abstract boolean shouldFetchLatestVersionsForOnlyInstalledPackages();
public abstract void fetchLatestVersion(@NotNull String packageName, @NotNull final CatchingConsumer<String, Exception> consumer);
public abstract void fetchLatestVersion(@NotNull InstalledPackage pkg, @NotNull final CatchingConsumer<String, Exception> consumer);
}
@@ -0,0 +1,104 @@
/*
* Copyright 2000-2014 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.ui.dialogs;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.ScrollPaneFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.ResourceBundle;
public class AgreementDialog extends DialogWrapper {
private final Font myFont = new Font("SansSerif", Font.PLAIN, 12);
private final ResourceBundle myBundle = ResourceBundle.getBundle("messages.LicenseCommonBundle");
private final String myText;
private JCheckBox myAcceptCheckBox;
private boolean myOK = false;
public AgreementDialog(String text, String programName) {
super(null, false, true);
getPeer().setAppIcons();
myText = text;
String title;
if (programName != null) {
title = MessageFormat.format(myBundle.getString("license.agreement.title.for"), programName);
}
else {
title = myBundle.getString("license.agreement.title");
}
setTitle(title);
init();
getOKAction().setEnabled(false);
}
protected void doOKAction() {
myOK = true;
super.doOKAction();
}
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new BorderLayout());
String text = myBundle.getString("license.agreement.prompt");
JLabel licensePrompt = new JLabel(text);
licensePrompt.setFocusable(false);
licensePrompt.setFont(myFont);
licensePrompt.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 5));
panel.add(licensePrompt, BorderLayout.WEST);
panel.add(new JPanel(), BorderLayout.CENTER);
return panel;
}
public boolean isAgreed() {
return myOK && myAcceptCheckBox.isSelected();
}
protected JComponent createCenterPanel() {
JPanel optionsPanel = new JPanel(new BorderLayout());
JTextArea licenseTextArea = new JTextArea(myText, 20, 50);
licenseTextArea.getCaret().setDot(0);
licenseTextArea.setFont(myFont);
licenseTextArea.setLineWrap(true);
licenseTextArea.setWrapStyleWord(true);
licenseTextArea.setEditable(false);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(licenseTextArea);
optionsPanel.add(scrollPane, BorderLayout.CENTER);
JPanel agreePanel = new JPanel(new GridLayout(1, 1));
agreePanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
myAcceptCheckBox = new JCheckBox(myBundle.getString("license.agreement.accept.checkbox"));
myAcceptCheckBox.setMnemonic(myAcceptCheckBox.getText().charAt(0));
myAcceptCheckBox.setFont(myFont);
agreePanel.add(myAcceptCheckBox);
optionsPanel.add(agreePanel, BorderLayout.SOUTH);
myAcceptCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
getOKAction().setEnabled(myAcceptCheckBox.isSelected());
}
});
return optionsPanel;
}
}
@@ -34,6 +34,10 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
myItems = new ArrayList<T>(items);
}
public CollectionListModel(@NotNull final List<? extends T> items) {
this((Collection<? extends T>)items);
}
public CollectionListModel(final T... items) {
myItems = ContainerUtilRt.newArrayList(items);
}
@@ -357,7 +357,7 @@ public class Alarm implements Disposable {
@Override
public String toString() {
Runnable task = getTask();
return super.toString() + (task != null ? " "+task:null);
return super.toString() + (task != null ? ": "+task : "");
}
}
@@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.intellij.util.net.ssl.CertificateWrapper.CommonField.COMMON_NAME;
import static com.intellij.util.net.ssl.CertificateUtil.getCommonName;
import static com.intellij.util.net.ssl.ConfirmingTrustManager.MutableTrustManager;
/**
@@ -63,7 +63,7 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
if (!new CertificateWrapper(certificate).isValid()) {
setForeground(UIUtil.getLabelDisabledForeground());
}
setText(new CertificateWrapper(certificate).getSubjectField(COMMON_NAME));
setText(getCommonName(certificate));
}
});
@@ -136,7 +136,7 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
myDetailsPanel.add(scrollPane, uniqueName);
}
private String getCardName(X509Certificate certificate) {
private static String getCardName(X509Certificate certificate) {
return certificate.getSubjectX500Principal().getName();
}
@@ -203,13 +203,13 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
for (X509Certificate certificate : added) {
if (!myTrustManager.addCertificate(certificate)) {
throw new ConfigurationException("Cannot add certificate", "Cannot Add Certificate");
throw new ConfigurationException("Cannot add certificate for " + getCommonName(certificate), "Cannot Add Certificate");
}
}
for (X509Certificate certificate : removed) {
if (!myTrustManager.removeCertificate(certificate)) {
throw new ConfigurationException("Cannot remove certificate", "Cannot Remove Certificate");
throw new ConfigurationException("Cannot remove certificate for " + getCommonName(certificate), "Cannot Remove Certificate");
}
}
@@ -256,12 +256,18 @@ public class CertificateConfigurable implements SearchableConfigurable, Configur
@Override
public void certificateAdded(X509Certificate certificate) {
getListModel().add(certificate);
CollectionListModel<X509Certificate> model = getListModel();
if (model.getElementIndex(certificate) < 0) {
model.add(certificate);
}
addCertificatePanel(certificate);
}
@Override
public void certificateRemoved(X509Certificate certificate) {
getListModel().remove(certificate);
CollectionListModel<X509Certificate> model = getListModel();
if (model.getElementIndex(certificate) >= 0) {
model.remove(certificate);
}
}
}
@@ -63,4 +63,11 @@ public class CertificateUtil {
StreamUtil.closeStream(stream);
}
}
/**
* @return subjects common name, usually it's domain name pattern, e.g. *.github.com
*/
public static String getCommonName(@NotNull X509Certificate certificate) {
return new CertificateWrapper(certificate).getSubjectField(CertificateWrapper.CommonField.COMMON_NAME);
}
}
@@ -260,7 +260,7 @@ public class ConfirmingTrustManager extends ClientOnlyTrustManager {
}
private static String createAlias(@NotNull X509Certificate certificate) {
return new CertificateWrapper(certificate).getSubjectField(CertificateWrapper.CommonField.COMMON_NAME);
return CertificateUtil.getCommonName(certificate);
}
/**
@@ -287,6 +287,10 @@ public class ConfirmingTrustManager extends ClientOnlyTrustManager {
}
// for listeners
X509Certificate certificate = getCertificate(alias);
if (certificate == null) {
LOG.error("No certificate found for alias: " + alias);
return false;
}
myKeyStore.deleteEntry(alias);
flushKeyStore();
// trust manager should be updated each time its key store was modified
@@ -151,6 +151,8 @@ Tree.paintLines=false
Tree.textBackground=ffffff
Tree.selectionBorderColor=3875d6
EditorPane.background=ffffff
List.background=ffffff
Hyperlink.linkColor=589df6
@@ -57,10 +57,10 @@ public class LaterInvocator {
}
private static class RunnableInfo {
final Runnable runnable;
final ModalityState modalityState;
final Condition<Object> expired;
final ActionCallback callback;
@NotNull private final Runnable runnable;
@NotNull private final ModalityState modalityState;
@NotNull private final Condition<Object> expired;
@NotNull private final ActionCallback callback;
public RunnableInfo(@NotNull Runnable runnable,
@NotNull ModalityState modalityState,
@@ -74,7 +74,7 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "[runnable: " + runnable + "; state=" + modalityState + "] ";
return "[runnable: " + runnable + "; state=" + modalityState + (expired.value(null) ? "; expired" : "")+"] ";
}
}
@@ -88,21 +88,12 @@ public class LaterInvocator {
private static final EventDispatcher<ModalityStateListener> ourModalityStateMulticaster =
EventDispatcher.create(ModalityStateListener.class);
private static final ArrayList<RunnableInfo> ourForcedFlushQueue = new ArrayList<RunnableInfo>();
public static void addModalityStateListener(@NotNull ModalityStateListener listener) {
ourModalityStateMulticaster.addListener(listener);
}
private static final List<RunnableInfo> ourForcedFlushQueue = new ArrayList<RunnableInfo>();
public static void addModalityStateListener(@NotNull ModalityStateListener listener, @NotNull Disposable parentDisposable) {
ourModalityStateMulticaster.addListener(listener, parentDisposable);
}
public static void removeModalityStateListener(@NotNull ModalityStateListener listener) {
ourModalityStateMulticaster.removeListener(listener);
}
@NotNull
static ModalityStateEx modalityStateForWindow(@NotNull Window window) {
int index = ourModalEntities.indexOf(window);
@@ -113,9 +104,7 @@ public class LaterInvocator {
if (window instanceof Dialog && ((Dialog)window).isModal()) {
return ownerState.appendEntity(window);
}
else {
return ownerState;
}
return ownerState;
}
ArrayList<Object> result = new ArrayList<Object>();
@@ -132,27 +121,32 @@ public class LaterInvocator {
return new ModalityStateEx(result.toArray());
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable) {
return invokeLater(runnable, Conditions.FALSE);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) {
ModalityState modalityState = ModalityState.defaultModalityState();
return invokeLater(runnable, modalityState, expired);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
return invokeLater(runnable, modalityState, Conditions.FALSE);
}
@NotNull
public static ActionCallback invokeLater(@NotNull Runnable runnable,
@NotNull ModalityState modalityState,
@NotNull Condition<Object> expired) {
ourFrequentEventDetector.eventHappened();
final ActionCallback callback = new ActionCallback();
RunnableInfo runnableInfo = new RunnableInfo(runnable, modalityState, expired, callback);
synchronized (LOCK) {
ourQueue.add(new RunnableInfo(runnable, modalityState, expired, callback));
ourQueue.add(runnableInfo);
}
requestFlush();
return callback;
@@ -177,7 +171,7 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "InvokeAndWait[" + runnable.toString() + "]";
return "InvokeAndWait[" + runnable + "]";
}
};
invokeLater(runnable1, modalityState);
@@ -326,7 +320,7 @@ public class LaterInvocator {
lastInfo.callback.setDone();
}
catch (ProcessCanceledException ex) {
// ignore
// ignore
}
catch (Throwable t) {
if (t instanceof StackOverflowError) {
@@ -348,20 +342,23 @@ public class LaterInvocator {
@NonNls
public String toString() {
return "LaterInvocator[lastRunnable=" + myLastInfo + "]";
return "LaterInvocator.FlushQueue" + (myLastInfo == null ? "" : " lastInfo="+myLastInfo);
}
}
@TestOnly
public static List<Object> dumpQueue() {
static String dumpQueue() {
synchronized (LOCK) {
if (!ourQueue.isEmpty()) {
ArrayList<Object> r = new ArrayList<Object>();
r.addAll(ourQueue);
Collections.reverse(r);
return r;
@NonNls String result = "";
if (!ourForcedFlushQueue.isEmpty()) {
result = "(Forced queue: " + ourForcedFlushQueue + ") ";
}
List<RunnableInfo> r = new ArrayList<RunnableInfo>(ourQueue);
result += r + (ourQueueSkipCount == 0 ? "" : " (ourQueueSkipCount="+ourQueueSkipCount+")")
+ (ourModalEntities.isEmpty() ? " (non-modal)" : " (modal entities: "+ourModalEntities+")"
+ (FLUSHER_SCHEDULED.get() ? " (Flusher scheduled)" : "")
);
return result;
}
return null;
}
}
@@ -0,0 +1,103 @@
/*
* Copyright 2000-2014 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.diff.actions;
import com.intellij.CommonBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.Map;
public class HighlightModeAction extends ComboBoxAction implements DumbAware {
private final Map<HighlightMode, AnAction> myActions = new HashMap<HighlightMode, AnAction>();
private static final HighlightMode[] ourActionOrder =
new HighlightMode[]{HighlightMode.BY_WORD, HighlightMode.BY_LINE, HighlightMode.NO_HIGHLIGHTING};
public HighlightModeAction() {
myActions.put(HighlightMode.BY_WORD,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.by.word"), HighlightMode.BY_WORD));
myActions.put(HighlightMode.BY_LINE,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.by.line"), HighlightMode.BY_LINE));
myActions.put(HighlightMode.NO_HIGHLIGHTING,
new SetHighlightModeAction(DiffBundle.message("diff.acton.highlight.mode.action.no.highlighting"),
HighlightMode.NO_HIGHLIGHTING));
}
@Override
public JComponent createCustomComponent(final Presentation presentation) {
JPanel panel = new JPanel(new BorderLayout());
final JLabel label = new JLabel(CommonBundle.message("diff.acton.highlight.mode.action.name"));
label.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
panel.add(label, BorderLayout.WEST);
panel.add(super.createCustomComponent(presentation), BorderLayout.CENTER);
return panel;
}
@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
DefaultActionGroup actionGroup = new DefaultActionGroup();
for (HighlightMode comparisonPolicy : ourActionOrder) {
actionGroup.add(myActions.get(comparisonPolicy));
}
return actionGroup;
}
public void update(AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
DiffPanelEx diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null && diffPanel.getComponent().isDisplayable()) {
AnAction action = myActions.get(diffPanel.getHighlightMode());
Presentation templatePresentation = action.getTemplatePresentation();
presentation.setIcon(templatePresentation.getIcon());
presentation.setText(templatePresentation.getText());
presentation.setEnabled(true);
}
else {
presentation.setIcon(null);
presentation.setText(DiffBundle.message("diff.acton.highlight.mode.not.available.action.name"));
presentation.setEnabled(false);
}
}
private static class SetHighlightModeAction extends AnAction implements DumbAware {
private final HighlightMode myHighlightMode;
public SetHighlightModeAction(String text, HighlightMode mode) {
super(text);
myHighlightMode = mode;
}
public void actionPerformed(AnActionEvent e) {
final DiffPanelImpl diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
diffPanel.setHighlightMode(myHighlightMode);
}
}
}
}
@@ -82,7 +82,7 @@ public class IgnoreWhiteSpacesAction extends ComboBoxAction implements DumbAware
}
}
private static class IgnoringPolicyAction extends AnAction {
private static class IgnoringPolicyAction extends AnAction implements DumbAware {
private final ComparisonPolicy myPolicy;
public IgnoringPolicyAction(String text, ComparisonPolicy policy) {
@@ -0,0 +1,50 @@
/*
* Copyright 2000-2014 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.diff.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.impl.DiffPanelImpl;
import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.ToggleActionButton;
import javax.swing.*;
public class ToggleAutoScrollAction extends ToggleActionButton implements DumbAware {
public ToggleAutoScrollAction() {
super("Auto Scroll", AllIcons.General.AutoscrollToSource);
}
@Override
public boolean isSelected(AnActionEvent e) {
DiffPanelEx diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
return diffPanel.isAutoScrollEnabled();
}
else {
return true;
}
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
final DiffPanelImpl diffPanel = DiffPanelImpl.fromDataContext(e.getDataContext());
if (diffPanel != null) {
diffPanel.setAutoScrollEnabled(state);
}
}
}
@@ -27,6 +27,7 @@ package com.intellij.openapi.diff.ex;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diff.DiffPanel;
import com.intellij.openapi.diff.impl.ComparisonPolicy;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.editor.Editor;
import org.jetbrains.annotations.Nullable;
@@ -41,4 +42,12 @@ public interface DiffPanelEx extends DiffPanel, Disposable {
void setComparisonPolicy(ComparisonPolicy comparisonPolicy);
ComparisonPolicy getComparisonPolicy();
void setAutoScrollEnabled(boolean enabled);
boolean isAutoScrollEnabled();
void setHighlightMode(HighlightMode highlightMode);
HighlightMode getHighlightMode();
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.*;
import com.intellij.openapi.diff.actions.MergeActionGroup;
import com.intellij.openapi.diff.actions.ToggleAutoScrollAction;
import com.intellij.openapi.diff.ex.DiffPanelEx;
import com.intellij.openapi.diff.ex.DiffPanelOptions;
import com.intellij.openapi.diff.impl.external.DiffManagerImpl;
@@ -33,6 +34,7 @@ import com.intellij.openapi.diff.impl.fragments.Fragment;
import com.intellij.openapi.diff.impl.fragments.FragmentList;
import com.intellij.openapi.diff.impl.highlighting.DiffPanelState;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.diff.impl.processing.HorizontalDiffSplitter;
import com.intellij.openapi.diff.impl.settings.DiffMergeEditorSetting;
import com.intellij.openapi.diff.impl.settings.DiffMergeSettings;
@@ -110,6 +112,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
public void customize(DiffToolbar toolbar) {
ActionManager actionManager = ActionManager.getInstance();
toolbar.addAction(actionManager.getAction("DiffPanel.Toolbar"));
toolbar.addSeparator();
toolbar.addAction(new ToggleAutoScrollAction());
toolbar.addSeparator();
toolbar.addAction(actionManager.getAction("ContextHelp"));
toolbar.addAction(getEditSourceAction());
toolbar.addSeparator();
@@ -467,10 +472,27 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
}
public void setAutoScrollEnabled(boolean enabled) {
myScrollSupport.setEnabled(enabled);
}
public boolean isAutoScrollEnabled() {
return myScrollSupport.isEnabled();
}
public void setComparisonPolicy(ComparisonPolicy comparisonPolicy) {
setComparisonPolicy(comparisonPolicy, true);
}
public void setHighlightMode(HighlightMode highlightMode) {
myData.setHighlightMode(highlightMode);
rediff();
}
public HighlightMode getHighlightMode() {
return myData.getHighlightMode();
}
public Rediffers getDiffUpdater() {
return myDiffUpdater;
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.diff.impl.fragments.FragmentList;
import com.intellij.openapi.diff.impl.fragments.FragmentListImpl;
import com.intellij.openapi.diff.impl.fragments.LineFragment;
import com.intellij.openapi.diff.impl.processing.DiffPolicy;
import com.intellij.openapi.diff.impl.processing.HighlightMode;
import com.intellij.openapi.diff.impl.processing.TextCompareProcessor;
import com.intellij.openapi.diff.impl.splitter.LineBlocks;
import com.intellij.openapi.project.Project;
@@ -37,6 +38,7 @@ import java.util.Iterator;
public abstract class SimpleDiffPanelState implements Disposable {
protected ComparisonPolicy myComparisonPolicy = ComparisonPolicy.DEFAULT;
protected DiffPolicy myDiffPolicy;
protected HighlightMode myHighlightMode;
protected final EditorPlaceHolder myAppender1;
protected final EditorPlaceHolder myAppender2;
protected FragmentList myFragmentList = FragmentList.EMPTY;
@@ -47,6 +49,7 @@ public abstract class SimpleDiffPanelState implements Disposable {
myAppender2 = createEditorWrapper(project, changeListener, FragmentSide.SIDE2);
myProject = project;
myDiffPolicy = DiffPolicy.LINES_WO_FORMATTING;
myHighlightMode = HighlightMode.BY_WORD;
Disposer.register(parentDisposable, this);
}
@@ -72,6 +75,14 @@ public abstract class SimpleDiffPanelState implements Disposable {
return myComparisonPolicy;
}
public HighlightMode getHighlightMode() {
return myHighlightMode;
}
public void setHighlightMode(HighlightMode highlightMode) {
myHighlightMode = highlightMode;
}
public void dispose() {
}
@@ -105,7 +116,12 @@ public abstract class SimpleDiffPanelState implements Disposable {
return LineBlocks.EMPTY;
}
return addMarkup(new TextCompareProcessor(myComparisonPolicy, myDiffPolicy).process(myAppender1.getText(), myAppender2.getText()));
if (myHighlightMode == HighlightMode.NO_HIGHLIGHTING) {
return LineBlocks.fromLineFragments(new ArrayList<LineFragment>());
}
return addMarkup(new TextCompareProcessor(myComparisonPolicy, myDiffPolicy, myHighlightMode == HighlightMode.BY_WORD)
.process(myAppender1.getText(), myAppender2.getText()));
}
public Project getProject() { return myProject; }
@@ -32,28 +32,38 @@ public class TextCompareProcessor {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.processing.Processor");
private final DiffPolicy myDiffPolicy;
@NotNull private final ComparisonPolicy myComparisonPolicy;
private final boolean mySearchForSubFragments;
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy, final DiffPolicy diffPolicy) {
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy,
final DiffPolicy diffPolicy,
boolean searchForSubFragments) {
myComparisonPolicy = comparisonPolicy;
myDiffPolicy = diffPolicy;
mySearchForSubFragments = searchForSubFragments;
}
public TextCompareProcessor(ComparisonPolicy comparisonPolicy) {
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy, final DiffPolicy diffPolicy) {
this(comparisonPolicy, diffPolicy, true);
}
public TextCompareProcessor(@NotNull ComparisonPolicy comparisonPolicy) {
this(comparisonPolicy, DiffPolicy.LINES_WO_FORMATTING);
}
public ArrayList<LineFragment> process(String text1, String text2) throws FilesTooBigForDiffException {
DiffFragment[] woFormattingBlocks = myDiffPolicy.buildFragments(text1, text2);
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(myComparisonPolicy).
correctAndNormalize(woFormattingBlocks);
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(myComparisonPolicy).correctAndNormalize(woFormattingBlocks);
ArrayList<LineFragment> lineBlocks = new DiffFragmentsProcessor().process(step1lineFragments);
for (LineFragment lineBlock : lineBlocks) {
if (lineBlock.isOneSide() || lineBlock.isEqual()) continue;
String subText1 = lineBlock.getText(text1, FragmentSide.SIDE1);
String subText2 = lineBlock.getText(text2, FragmentSide.SIDE2);
ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
lineBlock.adjustTypeFromChildrenTypes();
if (mySearchForSubFragments) {
for (LineFragment lineBlock : lineBlocks) {
if (lineBlock.isOneSide() || lineBlock.isEqual()) continue;
String subText1 = lineBlock.getText(text1, FragmentSide.SIDE1);
String subText2 = lineBlock.getText(text2, FragmentSide.SIDE2);
ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
lineBlock.adjustTypeFromChildrenTypes();
}
}
return lineBlocks;
}
@@ -36,6 +36,7 @@ public class SyncScrollSupport implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.util.SyncScrollSupport");
private boolean myDuringVerticalScroll = false;
private final ArrayList<ScrollListener> myScrollers = new ArrayList<ScrollListener>();
private boolean myEnabled = true;
public void install(EditingSides[] sideContainers) {
Disposer.dispose(this);
@@ -58,6 +59,14 @@ public class SyncScrollSupport implements Disposable {
myScrollers.clear();
}
public void setEnabled(boolean enabled) {
myEnabled = enabled;
}
public boolean isEnabled() {
return myEnabled;
}
private void install2(Editor[] editors, EditingSides[] sideContainers) {
addSlavesScroller(editors[0], new Pair<FragmentSide, EditingSides>(FragmentSide.SIDE1, sideContainers[0]));
addSlavesScroller(editors[1], new Pair<FragmentSide, EditingSides>(FragmentSide.SIDE2, sideContainers[0]));
@@ -100,7 +109,7 @@ public class SyncScrollSupport implements Disposable {
}
public void visibleAreaChanged(VisibleAreaEvent e) {
if (myDuringVerticalScroll) return;
if (!myEnabled || myDuringVerticalScroll) return;
Rectangle newRectangle = e.getNewRectangle();
Rectangle oldRectangle = e.getOldRectangle();
if (newRectangle == null || oldRectangle == null) return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -57,7 +57,7 @@ public class FileContentQueue {
private final Object myProceedWithProcessingLock = new Object();
private static final boolean ourAllowParallelFileReading = SystemProperties.getBooleanProperty("idea.allow.parallel.file.reading", true);
public void queue(final Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
public void queue(@NotNull Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
myFilesToLoadQueue.addAll(files);
final Runnable contentLoadingRunnable = new Runnable() {
@Override
@@ -38,6 +38,7 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
myTextField.setName(NAME);
}
@Override
public void selectAll() {
myTextField.selectAll();
myTextField.requestFocus();
@@ -48,18 +49,22 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
return myTextField.getEditor();
}
@Override
public EditorTextField getEditorComponent() {
return myTextField;
}
@Override
public void addActionListener(ActionListener l) {
}
@Override
public void removeActionListener(ActionListener l) {
}
@Override
public Object getItem() {
return getDocument();
}
@@ -68,6 +73,7 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
return myTextField.getDocument();
}
@Override
public void setItem(Object anObject) {
myTextField.setDocument((Document)anObject);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -95,7 +95,6 @@ public class AbstractPopup implements JBPopup {
private boolean myCancelOnWindowDeactivation = true;
private Dimension myForcedSize;
private Point myForcedLocation;
private ChildFocusWatcher myFocusWatcher;
private boolean myCancelKeyEnabled;
private boolean myLocateByContent;
protected FocusTrackback myFocusTrackback;
@@ -1037,7 +1036,7 @@ public class AbstractPopup implements JBPopup {
}
myFocusWatcher = new ChildFocusWatcher(myContent) {
ChildFocusWatcher focusWatcher = new ChildFocusWatcher(myContent) {
@Override
protected void onFocusGained(final FocusEvent event) {
setWindowActive(true);
@@ -1047,8 +1046,8 @@ public class AbstractPopup implements JBPopup {
protected void onFocusLost(final FocusEvent event) {
setWindowActive(false);
}
};
Disposer.register(this, focusWatcher);
mySpeedSearchPatternField = new JTextField();
if (SystemInfo.isMac) {
@@ -1058,7 +1057,7 @@ public class AbstractPopup implements JBPopup {
}
private Window updateMaskAndAlpha(Window window) {
if (window == null) return window;
if (window == null) return null;
final WindowManagerEx wndManager = getWndManager();
if (wndManager == null) return window;
@@ -1249,11 +1248,6 @@ public class AbstractPopup implements JBPopup {
}
myMouseOutCanceller = null;
if (myFocusWatcher != null) {
myFocusWatcher.dispose();
myFocusWatcher = null;
}
resetWindow();
if (myFinalRunnable != null) {
@@ -175,4 +175,5 @@ This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP Pro
This JVM property is old and its usage is not recommended by Oracle.\n\
\n(Note: It could have been assigned by some code dynamically.)
label.proxy.exceptions.text=Example\: *.domain.com, 192.168.*
checkbox.automatic.proxy.configuration.url=Automatic proxy configuration URL\:
checkbox.automatic.proxy.configuration.url=Automatic proxy configuration URL\:
diff.acton.highlight.mode.action.name=Highlighting Mode
@@ -83,3 +83,7 @@ diff.content.selected.value=Selected Value
diff.clipboard.vs.value.dialog.title=Clipboard vs Selected Value
diff.can.not.show.unknown=Can not show diff for unknown file type
diff.acton.highlight.mode.action.by.word=By Word
diff.acton.highlight.mode.action.by.line=By Line
diff.acton.highlight.mode.action.no.highlighting=No Highlighting
diff.acton.highlight.mode.not.available.action.name=<Not available>
@@ -1,392 +0,0 @@
[
{
"updateId": 11696,
"pluginId": "com.jetbrains.php",
"version": "121.12"
},
{
"updateId": 11749,
"pluginId": "com.jetbrains.php",
"version": "121.62"
},
{
"updateId": 11879,
"pluginId": "com.jetbrains.php",
"version": "121.215"
},
{
"updateId": 12109,
"pluginId": "com.jetbrains.php",
"version": "121.390"
},
{
"updateId": 12215,
"pluginId": "com.jetbrains.php",
"version": "122.875"
},
{
"updateId": 12290,
"pluginId": "com.jetbrains.php",
"version": "123.66"
},
{
"updateId": 12766,
"pluginId": "com.jetbrains.php",
"version": "126.334"
},
{
"updateId": 12851,
"pluginId": "com.jetbrains.php",
"version": "127.67"
},
{
"updateId": 12895,
"pluginId": "com.jetbrains.php",
"version": "127.100"
},
{
"updateId": 12992,
"pluginId": "com.jetbrains.php",
"version": "129.91"
},
{
"updateId": 13260,
"pluginId": "com.jetbrains.php",
"version": "129.362"
},
{
"updateId": 13473,
"pluginId": "com.jetbrains.php",
"version": "129.672"
},
{
"updateId": 13636,
"pluginId": "com.jetbrains.php",
"version": "129.814"
},
{
"updateId": 13711,
"pluginId": "com.jetbrains.php",
"version": "130.1176"
},
{
"updateId": 13843,
"pluginId": "com.jetbrains.php",
"version": "130.1481"
},
{
"updateId": 13933,
"pluginId": "com.jetbrains.php",
"version": "130.1639"
},
{
"updateId": 14135,
"pluginId": "com.jetbrains.php",
"version": "131.98"
},
{
"updateId": 14236,
"pluginId": "com.jetbrains.php",
"version": "131.205"
},
{
"updateId": 14260,
"pluginId": "com.jetbrains.php",
"version": "131.235"
},
{
"updateId": 14350,
"pluginId": "com.jetbrains.php",
"version": "131.332"
},
{
"updateId": 14379,
"pluginId": "com.jetbrains.php",
"version": "131.374"
},
{
"updateId": 14616,
"pluginId": "com.jetbrains.php",
"version": "133.51"
},
{
"updateId": 14858,
"pluginId": "com.jetbrains.php",
"version": "133.326"
},
{
"updateId": 14011,
"pluginId": "NodeJS",
"version": "132.15"
},
{
"updateId": 14203,
"pluginId": "NodeJS",
"version": "132.324"
},
{
"updateId": 14375,
"pluginId": "NodeJS",
"version": "132.709"
},
{
"updateId": 14482,
"pluginId": "NodeJS",
"version": "132.944"
},
{
"updateId": 14516,
"pluginId": "NodeJS",
"version": "132.947"
},
{
"updateId": 14548,
"pluginId": "NodeJS",
"version": "132.1054"
},
{
"updateId": 14581,
"pluginId": "NodeJS",
"version": "133.50"
},
{
"updateId": 14595,
"pluginId": "NodeJS",
"version": "133.74"
},
{
"updateId": 14665,
"pluginId": "NodeJS",
"version": "133.134"
},
{
"updateId": 14693,
"pluginId": "NodeJS",
"version": "133.162"
},
{
"updateId": 14706,
"pluginId": "NodeJS",
"version": "133.195"
},
{
"updateId": 14707,
"pluginId": "NodeJS",
"version": "133.193"
},
{
"updateId": 14715,
"pluginId": "NodeJS",
"version": "133.168"
},
{
"updateId": 14790,
"pluginId": "NodeJS",
"version": "133.260"
},
{
"updateId": 14820,
"pluginId": "NodeJS",
"version": "133.293"
},
{
"updateId": 14868,
"pluginId": "NodeJS",
"version": "133.373"
},
{
"updateId": 14031,
"pluginId": "org.intellij.clojure",
"version": "0.7.34"
},
{
"updateId": 14076,
"pluginId": "org.intellij.clojure",
"version": "0.7.36"
},
{
"updateId": 14428,
"pluginId": "org.intellij.clojure",
"version": "0.7.57"
},
{
"updateId": 14604,
"pluginId": "org.intellij.clojure",
"version": "0.7.60"
},
{
"updateId": 8976,
"pluginId": "org.intellij.scala",
"version": "0.4.407"
},
{
"updateId": 9009,
"pluginId": "org.intellij.scala",
"version": "0.4.442"
},
{
"updateId": 9041,
"pluginId": "org.intellij.scala",
"version": "0.4.472"
},
{
"updateId": 9214,
"pluginId": "org.intellij.scala",
"version": "0.4.589"
},
{
"updateId": 9343,
"pluginId": "org.intellij.scala",
"version": "0.4.748"
},
{
"updateId": 9470,
"pluginId": "org.intellij.scala",
"version": "0.4.820"
},
{
"updateId": 9473,
"pluginId": "org.intellij.scala",
"version": "0.4.833"
},
{
"updateId": 9669,
"pluginId": "org.intellij.scala",
"version": "0.4.1084"
},
{
"updateId": 9968,
"pluginId": "org.intellij.scala",
"version": "0.4.1371"
},
{
"updateId": 10010,
"pluginId": "org.intellij.scala",
"version": "0.5.16"
},
{
"updateId": 14027,
"pluginId": "org.intellij.scala",
"version": "0.18.39"
},
{
"updateId": 14075,
"pluginId": "org.intellij.scala",
"version": "0.21.45"
},
{
"updateId": 14130,
"pluginId": "org.intellij.scala",
"version": "0.21.50"
},
{
"updateId": 14289,
"pluginId": "org.intellij.scala",
"version": "0.23.252"
},
{
"updateId": 14440,
"pluginId": "org.intellij.scala",
"version": "0.23.282"
},
{
"updateId": 14493,
"pluginId": "org.intellij.scala",
"version": "0.23.289"
},
{
"updateId": 14574,
"pluginId": "org.intellij.scala",
"version": "0.23.308"
},
{
"updateId": 14612,
"pluginId": "org.intellij.scala",
"version": "0.23.311"
},
{
"updateId": 14666,
"pluginId": "org.intellij.scala",
"version": "0.26.308"
},
{
"updateId": 14672,
"pluginId": "org.intellij.scala",
"version": "0.26.310"
},
{
"updateId": 14697,
"pluginId": "org.intellij.scala",
"version": "0.26.314"
},
{
"updateId": 14711,
"pluginId": "org.intellij.scala",
"version": "0.26.315"
},
{
"updateId": 14728,
"pluginId": "org.intellij.scala",
"version": "0.26.318"
},
{
"updateId": 14743,
"pluginId": "org.intellij.scala",
"version": "0.26.321"
},
{
"updateId": 14767,
"pluginId": "org.intellij.scala",
"version": "0.26.323"
},
{
"updateId": 14779,
"pluginId": "org.intellij.scala",
"version": "0.26.327"
},
{
"updateId": 14845,
"pluginId": "org.intellij.scala",
"version": "0.26.331"
},
{
"updateId": 14859,
"pluginId": "org.intellij.scala",
"version": "0.26.333"
},
{
"updateId": 14863,
"pluginId": "org.intellij.scala",
"version": "0.26.335"
},
{
"updateId": 14627,
"pluginId": "org.jetbrains.plugins.ruby",
"version": "6.0.0.20131121"
},
{
"updateId": 14812,
"pluginId": "org.jetbrains.plugins.ruby",
"version": "6.0.0.20131207"
},
{
"updateId": 14036,
"pluginId": "Pythonid",
"version": "2.11.2"
},
{
"updateId": 14295,
"pluginId": "Pythonid",
"version": "3.0.1"
},
{
"updateId": 14654,
"pluginId": "Pythonid",
"version": "3.1 Beta"
},
{
"updateId": 14824,
"pluginId": "Pythonid",
"version": "3.1 Beta 2"
}
]
@@ -0,0 +1,6 @@
// This file contains list of broken plugins.
// Each line contains plugin ID and list of versions that are broken.
// If plugin name or version contains a space you can quote it like in command line.
NodeJS 134.680 134.31 134.307 134.262 134.198 134.125
com.jetbrains.php 133.51 133.326 131.98 131.374 131.332 131.235 131.205 130.1639 130.1481 130.1176 129.91 129.814 129.672 129.362 127.67 127.100 126.334 123.66 122.875 121.62 121.390 121.215 121.12
@@ -550,6 +550,8 @@
<reference ref="NextDiff"/>
<separator/>
<action id="Diff.IgnoreWhitespace" class="com.intellij.openapi.diff.actions.IgnoreWhiteSpacesAction" text=""/>
<separator/>
<action id="Diff.HighlightMode" class="com.intellij.openapi.diff.actions.HighlightModeAction" text=""/>
</group>
<group id="ChangeScheme">
@@ -0,0 +1,20 @@
/*
* Copyright 2000-2014 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.diff.impl.processing;
public enum HighlightMode {
BY_WORD, BY_LINE, NO_HIGHLIGHTING
}
@@ -15,6 +15,10 @@
*/
package com.intellij.openapi.util;
/**
* Throw this exception from {@link JDOMExternalizable#writeExternal(org.jdom.Element)} method if you don't want to store any settings.
* If you simply return from the method empty '<component name=... />' tag will be written leading to unneeded modification of configuration files.
*/
public class WriteExternalException extends Exception {
public WriteExternalException() {
super();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,28 +18,26 @@ package com.intellij.util.containers;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.RandomAccess;
import java.util.Set;
public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAccess {
// have to extend ArrayList because otherwise the spliterator() methods declared in Set and List are in conflict
public class OrderedSet<T> extends ArrayList<T> implements Set<T>, RandomAccess {
private final OpenTHashSet<T> myHashSet;
private final ArrayList<T> myElements;
public OrderedSet() {
this(ContainerUtil.<T>canonicalStrategy());
}
public OrderedSet(TObjectHashingStrategy<T> hashingStrategy) {
public OrderedSet(@NotNull TObjectHashingStrategy<T> hashingStrategy) {
this(hashingStrategy, 4);
}
public OrderedSet(TObjectHashingStrategy<T> hashingStrategy, int capacity) {
public OrderedSet(@NotNull TObjectHashingStrategy<T> hashingStrategy, int capacity) {
super(capacity);
myHashSet = new OpenTHashSet<T>(capacity, hashingStrategy);
myElements = new ArrayList<T>(capacity);
}
@Override
public int size() {
return myElements.size();
}
@Override
@@ -50,7 +48,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public boolean add(T o) {
if (myHashSet.add(o)){
myElements.add(o);
super.add(o);
return true;
}
return false;
@@ -59,7 +57,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public boolean remove(Object o) {
if (myHashSet.remove(o)){
myElements.remove(o);
super.remove(o);
return true;
}
return false;
@@ -68,19 +66,7 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public void clear() {
myHashSet.clear();
myElements.clear();
}
@NotNull
@Override
public Object[] toArray() {
return myElements.toArray();
}
@NotNull
@Override
public <T> T[] toArray(@NotNull T[] a) {
return myElements.toArray(a);
super.clear();
}
@Override
@@ -88,11 +74,6 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
throw new UnsupportedOperationException();
}
@Override
public T get(final int index) {
return myElements.get(index);
}
@Override
public T set(final int index, final T element) {
final T removed = remove(index);
@@ -103,13 +84,13 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public void add(final int index, final T element) {
if (myHashSet.add(element)){
myElements.add(index, element);
super.add(index, element);
}
}
@Override
public T remove(final int index) {
final T t = myElements.remove(index);
final T t = super.remove(index);
myHashSet.remove(t);
return t;
}
@@ -117,24 +98,12 @@ public class OrderedSet<T> extends AbstractList<T> implements Set<T>, RandomAcce
@Override
public int indexOf(final Object o) {
final int index = myHashSet.index((T)o);
return index >= 0? myElements.indexOf(myHashSet.get(index)) : -1;
return index >= 0? super.indexOf(myHashSet.get(index)) : -1;
}
@Override
public int lastIndexOf(final Object o) {
final int index = myHashSet.index((T)o);
return index >= 0 ? myElements.lastIndexOf(myHashSet.get(index)) : -1;
}
@NotNull
@Override
public ListIterator<T> listIterator() {
return myElements.listIterator();
}
@NotNull
@Override
public ListIterator<T> listIterator(final int index) {
return myElements.listIterator(index);
return index >= 0 ? super.lastIndexOf(myHashSet.get(index)) : -1;
}
}
@@ -96,6 +96,7 @@ public class URLUtil {
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipFile zipFile = new ZipFile(FileUtil.unquote(paths.first));
ZipEntry zipEntry = zipFile.getEntry(paths.second);
if (zipEntry == null) {
zipFile.close();
throw new FileNotFoundException("Entry " + paths.second + " not found in " + paths.first);
}
@@ -356,9 +356,9 @@ public class UIUtil {
public static void setEnabled(Component component, boolean enabled, boolean recursively) {
component.setEnabled(enabled);
if (component instanceof JComboBox) {
if (component instanceof JComboBox && isUnderAquaLookAndFeel()) {
// On Mac JComboBox instances have children: com.apple.laf.AquaComboBoxButton and javax.swing.CellRendererPane.
// Disabling these children results in ugly UI. See WEB-10733
// Disabling these children results in ugly UI: WEB-10733
return;
}
if (component instanceof JLabel) {
@@ -809,6 +809,8 @@ public class XmlSerializerTest extends TestCase {
public int COUNT = 3;
@Attribute("name")
public String name = "James";
@Attribute("occupation")
public String occupation;
}
public void testBeanWithPrimitivePropertyBoundToAttribute() {
final BeanWithPropertiesBoundToAttribute bean = new BeanWithPropertiesBoundToAttribute();
@@ -851,7 +853,7 @@ public class XmlSerializerTest extends TestCase {
bean.STRING_V = "skip";
assertSerializer(bean, "<BeanWithPropertyFilter />", "Serialization failure", null);
assertSerializer(bean, "<BeanWithPropertyFilter />", null);
}
public static class BeanWithJDOMElement {
@@ -1145,13 +1147,13 @@ public class XmlSerializerTest extends TestCase {
}
//---------------------------------------------------------------------------------------------------
private static void assertSerializer(Object bean, String expected, SerializationFilter filter) {
assertSerializer(bean, expected, "Serialization failure", filter);
private static Element assertSerializer(Object bean, String expected, SerializationFilter filter) {
return assertSerializer(bean, expected, "Serialization failure", filter);
}
private static Object doSerializerTest(String expectedText, Object bean) {
try {
Element element = assertSerializer(bean, expectedText, "Serialization failure", null);
Element element = assertSerializer(bean, expectedText, null);
//test deserializer
@@ -37,6 +37,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull private final Project myProject;
@NotNull private final ProjectRootManager myProjectManager;
@NotNull private final ProjectLevelVcsManager myVcsManager;
@NotNull private final VcsRootChecker[] myCheckers;
public VcsRootDetectorImpl(@NotNull Project project,
@NotNull ProjectRootManager projectRootManager,
@@ -44,6 +45,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
myProject = project;
myProjectManager = projectRootManager;
myVcsManager = projectLevelVcsManager;
myCheckers = Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME);
}
@NotNull
@@ -53,7 +55,7 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull
public Collection<VcsRoot> detect(@Nullable VirtualFile startDir) {
if (startDir == null) {
if (startDir == null || myCheckers.length == 0) {
return Collections.emptyList();
}
@@ -140,9 +142,8 @@ public class VcsRootDetectorImpl implements VcsRootDetector {
@NotNull
private List<AbstractVcs> getVcsListFor(@NotNull VirtualFile dir) {
VcsRootChecker[] checkers = Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME);
List<AbstractVcs> vcsList = new ArrayList<AbstractVcs>();
for (VcsRootChecker checker : checkers) {
for (VcsRootChecker checker : myCheckers) {
if (checker.isRoot(dir.getPath())) {
vcsList.add(myVcsManager.findVcsByName(checker.getSupportedVcs().getName()));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -322,7 +322,7 @@ public class XDebugSessionImpl implements XDebugSession {
return myValueMarkers;
}
private static <B extends XBreakpoint<?>> XBreakpointType<?, ?> getBreakpointTypeClass(final XBreakpointHandler<B> handler) {
private static XBreakpointType getBreakpointTypeClass(final XBreakpointHandler handler) {
return XDebuggerUtil.getInstance().findBreakpointType(handler.getBreakpointTypeClass());
}
@@ -262,9 +262,13 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
@Override
@Nullable
public PsiElement findContextElement(@NotNull VirtualFile virtualFile, int offset, @NotNull Project project, boolean checkXml) {
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (file == null || document == null) {
PsiFile file = document == null ? null : PsiManager.getInstance(project).findFile(virtualFile);
if (file == null) {
return null;
}
@@ -60,6 +60,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
return myComboBox;
}
@Override
public JComponent getComponent() {
return myComboBox;
}
@@ -70,7 +71,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
public JComponent getEditorComponent() {
return (JComponent)myEditor.getEditorComponent();
return myEditor.getEditorComponent();
}
public void setEnabled(boolean enable) {
@@ -89,13 +90,12 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
private void initEditor() {
myEditor = new EditorComboBoxEditor(getProject(), myDebuggerEditorsProvider.getFileType()) {
@Override
public void setItem(Object anObject) {
if (anObject == null) {
anObject = "";
}
super.setItem(createDocument((String)anObject));
super.setItem(createDocument(StringUtil.notNullize((String)anObject)));
}
@Override
public Object getItem() {
return ((Document)super.getItem()).getText();
}
@@ -106,6 +106,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS);
}
@Override
protected void onHistoryChanged() {
fillComboBox();
}
@@ -120,6 +121,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
}
@Override
protected void doSetText(String text) {
if (myComboBox.getItemCount() > 0) {
myComboBox.setSelectedIndex(0);
@@ -133,15 +135,18 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase {
}
}
@Override
public String getText() {
final Object value = myComboBox.isPopupVisible() ? myComboBox.getPopup().getList().getSelectedValue() : myEditor.getItem();
return StringUtil.notNullize((String)value);
}
@Override
public JComponent getPreferredFocusedComponent() {
return (JComponent)myComboBox.getEditor().getEditorComponent();
}
@Override
public void selectAll() {
myComboBox.getEditor().selectAll();
}
@@ -454,10 +454,6 @@
key="missing.deprecated.annotation.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING" runForWholeFile="true"
implementationClass="com.siyeh.ig.classlayout.MissingDeprecatedAnnotationInspection"/>
<localInspection language="JAVA" suppressId="override" shortName="MissingOverrideAnnotation" bundle="com.siyeh.InspectionGadgetsBundle"
key="missing.override.annotation.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.classlayout.MissingOverrideAnnotationInspection"/>
<localInspection language="JAVA" shortName="MultipleTopLevelClassesInFile" bundle="com.siyeh.InspectionGadgetsBundle"
key="multiple.top.level.classes.in.file.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING"
@@ -507,6 +503,10 @@
key="method.return.always.constant.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.classlayout.MethodReturnAlwaysConstantInspection"/>
<localInspection language="JAVA" shortName="InterfaceMayBeAnnotatedFunctional" bundle="com.siyeh.InspectionGadgetsBundle"
key="interface.may.be.annotated.functional.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.classlayout.InterfaceMayBeAnnotatedFunctionalInspection"/>
<!--group.names.class.metrics-->
<localInspection language="JAVA" suppressId="OverlyComplexAnonymousInnerClass" shortName="AnonymousClassComplexity"
@@ -1028,6 +1028,10 @@
key="type.parameter.extends.final.class.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.inheritance.issues" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.inheritance.TypeParameterExtendsFinalClassInspection"/>
<localInspection language="JAVA" suppressId="override" shortName="MissingOverrideAnnotation" bundle="com.siyeh.InspectionGadgetsBundle"
key="missing.override.annotation.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.inheritance.issues" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.inheritance.MissingOverrideAnnotationInspection"/>
<!--group.names.initialization.issues-->
<localInspection language="JAVA" shortName="AbstractMethodCallInConstructor" bundle="com.siyeh.InspectionGadgetsBundle"
@@ -2063,3 +2063,5 @@ suppress.for.tests.scope.quickfix=Suppress for 'Tests' scope
implicit.default.charset.usage.display.name=Implicit usage of platform's default charset
implicit.default.charset.usage.problem.descriptor=Call to <code>#ref()</code> uses the platform's default charset
implicit.default.charset.usage.constructor.problem.descriptor=<code>new #ref()</code> call uses the platform's default charset
interface.may.be.annotated.functional.display.name=Interface may be annotated @FunctionalInterface
interface.may.be.annotated.functional.problem.descriptor=Interface <code>#ref</code> may be annotated with @FunctionalInterface
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.PsiReplacementUtil;
import com.siyeh.ig.psiutils.ClassUtils;
import org.jetbrains.annotations.NotNull;
public class StaticCallOnSubclassInspection extends BaseInspection {
@@ -141,10 +140,8 @@ public class StaticCallOnSubclassInspection extends BaseInspection {
if (declaringClass.equals(referencedClass)) {
return;
}
final PsiClass containingClass =
ClassUtils.getContainingClass(call);
if (!ClassUtils.isClassVisibleFromClass(containingClass,
declaringClass)) {
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(call.getProject()).getResolveHelper();
if (!resolveHelper.isAccessible(declaringClass, call, null)) {
return;
}
registerMethodCallError(call, declaringClass, referencedClass);
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2008 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.PsiReplacementUtil;
import com.siyeh.ig.psiutils.ClassUtils;
import org.jetbrains.annotations.NotNull;
public class StaticFieldReferenceOnSubclassInspection
@@ -124,13 +123,14 @@ public class StaticFieldReferenceOnSubclassInspection
if (declaringClass.equals(referencedClass)) {
return;
}
final PsiClass containingClass =
ClassUtils.getContainingClass(expression);
if (!ClassUtils.isClassVisibleFromClass(containingClass,
declaringClass)) {
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper();
if (!resolveHelper.isAccessible(declaringClass, expression, null)) {
return;
}
final PsiElement identifier = expression.getReferenceNameElement();
if (identifier == null) {
return;
}
registerError(identifier, declaringClass, referencedClass);
}
}
@@ -0,0 +1,91 @@
/*
* Copyright 2000-2014 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.siyeh.ig.classlayout;
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
import com.intellij.psi.LambdaHighlightingUtil;
import com.intellij.psi.LambdaUtil;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiNameValuePair;
import com.intellij.psi.util.MethodSignature;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.DelegatingFix;
import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author Bas Leijdekkers
*/
public class InterfaceMayBeAnnotatedFunctionalInspection extends BaseInspection {
@Nls
@NotNull
@Override
public String getDisplayName() {
return InspectionGadgetsBundle.message("interface.may.be.annotated.functional.display.name");
}
@NotNull
@Override
protected String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message("interface.may.be.annotated.functional.problem.descriptor");
}
@Nullable
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiClass aClass = (PsiClass)infos[0];
return new DelegatingFix(new AddAnnotationPsiFix(LambdaUtil.JAVA_LANG_FUNCTIONAL_INTERFACE, aClass, PsiNameValuePair.EMPTY_ARRAY));
}
@Override
public BaseInspectionVisitor buildVisitor() {
return new InterfaceMayBeAnnotatedFunctionalVisitor();
}
private static class InterfaceMayBeAnnotatedFunctionalVisitor extends BaseInspectionVisitor {
@Override
public void visitClass(PsiClass aClass) {
if (!PsiUtil.isLanguageLevel8OrHigher(aClass)) {
return;
}
super.visitClass(aClass);
if (!aClass.isInterface()) {
return;
}
if (LambdaHighlightingUtil.checkInterfaceFunctional(aClass) != null) {
return;
}
final List<MethodSignature> candidates = LambdaUtil.findFunctionCandidates(aClass);
if (candidates == null || candidates.size() != 1) {
return;
}
final MethodSignature signature = candidates.get(0);
if (signature.getTypeParameters().length > 0) {
return;
}
registerClassError(aClass, aClass);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.ig.classlayout;
package com.siyeh.ig.inheritance;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -206,21 +206,4 @@ public class ClassUtils {
final PsiClass parentClass = (PsiClass)parent;
return !parentClass.isInterface();
}
public static boolean isClassVisibleFromClass(PsiClass baseClass,
PsiClass referencedClass) {
if (referencedClass.hasModifierProperty(PsiModifier.PUBLIC)) {
return true;
}
else if (referencedClass.hasModifierProperty(PsiModifier.PROTECTED)) {
return inSamePackage(baseClass, referencedClass);
}
else if (referencedClass.hasModifierProperty(PsiModifier.PRIVATE)) {
return PsiTreeUtil.findCommonParent(baseClass, referencedClass) !=
null;
}
else {
return inSamePackage(baseClass, referencedClass);
}
}
}
@@ -0,0 +1,10 @@
<html>
<body>
Reports any <b>interface</b> that may be annotated as <b>@FunctionalInterface</b>, which is available in JDK 1.8.
Annotating an interface with <b>@FunctionalInterface</b> can be useful to indicate that the interface is supposed to be functional and
further <b>abstract</b> methods should not be added to it.
This inspection only reports if the project or module is configured to use a language level of 8.0 or higher.
<p>
<small>New in 13.1</small>
</body>
</html>
@@ -1,17 +0,0 @@
package com.siyeh.igtest.bugs;
import com.siyeh.igtest.abstraction.StaticCallOnSubclassChild;
public class StaticCallOnSubclass {
public void foo() throws InterruptedException {
Thread.sleep(1000L);
InnerThread.sleep(1000L, 1000);
final int priority = InnerThread.MAX_PRIORITY;
StaticCallOnSubclassChild.foo();
}
class InnerThread extends Thread
{
}
}
@@ -0,0 +1,54 @@
/*
* Copyright 2000-2014 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.siyeh.ig.bugs;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
/**
* @author Bas Leijdekkers
*/
public class StaticFieldReferenceOnSubclassInspectionTest extends LightInspectionTestCase {
@Override
protected InspectionProfileEntry getInspection() {
return new StaticFieldReferenceOnSubclassInspection();
}
@Override
protected String[] getEnvironmentClasses() {
return new String[] {
"package a;" +
"public class A {" +
" private static class AA {\n" +
" public static final int VALUE = 5;\n" +
" }" +
" public static class AB extends AA {\n" +
" }" +
" public static final String S = \"\";" +
"}",
"package a;" +
"public class B extends A {}"
};
}
public void testSimple() {
doStatementTest("System.out.println(a.B./*Static field 'S' declared in class 'a.A' but referenced via subclass 'a.B'*/S/**/);");
}
public void testNoWarn() {
doStatementTest("System.out.println(a.A.AB.VALUE);");
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2000-2014 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.siyeh.ig.classlayout;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
/**
* @author Bas Leijdekkers
*/
public class InterfaceMayBeAnnotatedFunctionalInspectionTest extends LightInspectionTestCase {
public void testSimple() {
doTest("interface /*Interface 'Simple' may be annotated with @FunctionalInterface*/Simple/**/ {" +
" void f();" +
"}");
}
public void testLessSimple() {
doTest("interface /*Interface 'F' may be annotated with @FunctionalInterface*/F/**/ {" +
" boolean equals(Object o);" +
" static void f00() {}\n" +
" default void g() {}\n" +
" void f();\n" +
"}");
}
public void testNotFunctional() {
doTest("interface G {" +
"<T> void f();" +
"}");
}
@Override
protected InspectionProfileEntry getInspection() {
return new InterfaceMayBeAnnotatedFunctionalInspection();
}
}
@@ -178,7 +178,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
}
private static boolean doInjectInJava(final Project project,
final PsiElement psiElement,
@NotNull final PsiElement psiElement,
PsiLanguageInjectionHost host,
final String languageId) {
final PsiElement target = ContextComputationProcessor.getTopLevelInjectionTarget(psiElement);
@@ -245,7 +245,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
return false;
}
new WriteCommandAction(modifierListOwner.getProject(), modifierListOwner.getContainingFile()) {
protected void run(final Result result) throws Throwable {
protected void run(@NotNull final Result result) throws Throwable {
JVMElementFactory factory = JVMElementFactories.getFactory(modifierListOwner.getLanguage(), modifierListOwner.getProject());
if (factory == null) {
factory = JavaPsiFacade.getElementFactory(modifierListOwner.getProject());
@@ -484,7 +484,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
}
}
}
else {
// else {
// todo tbd
//for (InjectionPlace place : injection.getInjectionPlaces()) {
// final Matcher matcher = pattern.matcher(place.getText());
@@ -492,7 +492,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
//
// }
//}
}
// }
result.setMethodInfos(infos);
result.generatePlaces();
return result;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -75,7 +75,7 @@ public abstract class DevKitInspectionBase extends BaseJavaLocalInspectionTool {
@Nullable
private static Set<PsiClass> checkModule(Module module, PsiClass psiClass, @Nullable Set<PsiClass> types, boolean includeActions) {
final XmlFile pluginXml = PluginModuleType.getPluginXml(module);
if (!isPluginXml(pluginXml)) return types;
if (!DescriptorUtil.isPluginXml(pluginXml)) return types;
assert pluginXml != null;
final XmlDocument document = pluginXml.getDocument();
@@ -100,17 +100,6 @@ public abstract class DevKitInspectionBase extends BaseJavaLocalInspectionTool {
return types;
}
public static boolean isPluginXml(PsiFile file) {
if (!(file instanceof XmlFile)) return false;
final XmlFile pluginXml = (XmlFile)file;
final XmlDocument document = pluginXml.getDocument();
if (document == null) return false;
final XmlTag rootTag = document.getRootTag();
return rootTag != null && "idea-plugin".equals(rootTag.getLocalName());
}
@Nullable
protected static PsiElement getAttValueToken(@NotNull XmlAttribute attribute) {
final XmlAttributeValue valueElement = attribute.getValueElement();

Some files were not shown because too many files have changed in this diff Show More