Merge remote-tracking branch 'origin/master'

This commit is contained in:
Artemiy Sartakov
2019-03-13 16:19:05 +07:00
32 changed files with 179 additions and 120 deletions
Binary file not shown.
+1 -1
View File
@@ -4,6 +4,6 @@ kotlinPluginBuild=1.3.21-release-IJ2019.1-2
jetSignBuild=42.30
secondJreVersion=11
secondJreBuild=11_0_2b185.4
bundledMavenVersion=3.3.9
bundledMavenVersion=3.6.0
jdkBuild=u202b1514.10
gradleApiVersion=4.10.3
+1 -1
View File
@@ -31,7 +31,7 @@ dependencies {
}
def communityPluginsDir = project.file("../../plugins")
def mavenServerLibDir = "$communityPluginsDir/maven/maven3-server-impl/lib/"
def mavenServerLibDir = "$communityPluginsDir/maven/maven36-server-impl/lib/"
def mavenDistName = "apache-maven-$bundledMavenVersion"
task unpackMavenDistribution( type: Copy) {
@@ -302,7 +302,7 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement
result.addAll(getNotNulls());
result.addAll(getNullables());
result.addAll(ContainerUtil.mapNotNull(getAllNullabilityNickNames(), PsiClass::getQualifiedName));
return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT);
return CachedValueProvider.Result.create(Collections.unmodifiableSet(result), PsiModificationTracker.MODIFICATION_COUNT);
});
}
@@ -15,10 +15,7 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.*;
import static com.intellij.codeInsight.AnnotationUtil.*;
@@ -256,8 +253,12 @@ public abstract class NullableNotNullManager {
private NullabilityAnnotationInfo doFindEffectiveNullabilityAnnotation(@NotNull PsiModifierListOwner owner) {
List<String> nullables = getNullablesWithNickNames();
Set<String> annotationNames = getAllNullabilityAnnotationsWithNickNames();
Set<String> extraAnnotations = DEFAULT_ALL.stream().filter(anno -> !annotationNames.contains(anno)).collect(Collectors.toSet());
annotationNames.addAll(extraAnnotations);
Set<String> extraAnnotations = new HashSet<>(DEFAULT_ALL);
extraAnnotations.removeAll(annotationNames);
if (!extraAnnotations.isEmpty()) {
annotationNames = new HashSet<>(annotationNames);
annotationNames.addAll(extraAnnotations);
}
PsiAnnotation annotation = findPlainAnnotation(owner, true, annotationNames);
if (annotation != null) {
@@ -360,7 +361,7 @@ public abstract class NullableNotNullManager {
protected Set<String> getAllNullabilityAnnotationsWithNickNames() {
Set<String> qNames = ContainerUtil.newHashSet(getNullablesWithNickNames());
qNames.addAll(getNotNullsWithNickNames());
return qNames;
return Collections.unmodifiableSet(qNames);
}
protected boolean hasHardcodedContracts(@NotNull PsiElement element) {
@@ -0,0 +1,5 @@
<idea-plugin>
<id>main</id>
<depends optional="true" config-file="dep2.xml">dep2</depends>
<depends optional="true" config-file="dep1.xml">dep1</depends>
</idea-plugin>
+1 -1
View File
@@ -30,7 +30,7 @@
NSTouchBarItem * result = (*_jcreator)([identifier UTF8String]);
if (result == nil)
nserror(@"tb [%@]: can't make item for uid '%@'", identifier);
nserror(@"tb [%@]: can't make item for uid '%@'", self.name, identifier);
return result;
}
@@ -344,11 +344,11 @@ class CommunityLibraryLicenses {
libraryName: 'org.apache.maven:maven-aether-provider',
additionalLibraryNames: ['org.apache.maven:maven-model-builder', 'org.apache.maven:maven-artifact', 'org.apache.maven:maven-repository-metadata', 'org.apache.maven:maven-builder-support'],
licenseUrl: "http://apache.org/licenses/LICENSE-2.0"),
new LibraryLicense(name: "Maven Model", version: "3.3.9", libraryName: "maven-model", license: "Apache 2.0",
new LibraryLicense(name: "Maven Model", version: "3.6.0", libraryName: "maven-model", license: "Apache 2.0",
url: "http://maven.apache.org/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0"),
new LibraryLicense(name: "Maven3", attachedTo: "intellij.maven.server.m3.common",
additionalLibraryNames: ["org.apache.maven.shared:maven-dependency-tree:1.2", "org.apache.maven.archetype:archetype-common:2.2"],
version: "3.3.9", license: "Apache 2.0", url: "http://maven.apache.org/",
version: "3.6.0", license: "Apache 2.0", url: "http://maven.apache.org/",
licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0"),
new LibraryLicense(name: "Memory File System", libraryName: "memoryfilesystem", version: "1.3.0", license: "MIT",
url: "https://github.com/marschall/memoryfilesystem", licenseUrl: "http://opensource.org/licenses/MIT"),
@@ -158,7 +158,7 @@ class CommunityRepositoryModules {
withModule("intellij.maven.artifactResolver.common", "artifact-resolver-m3.jar")
withModule("intellij.maven.artifactResolver.m31", "artifact-resolver-m31.jar")
withModule("intellij.maven.artifactResolver.common", "artifact-resolver-m31.jar")
withResource("maven3-server-impl/lib/maven3", "lib/maven3")
withResource("maven36-server-impl/lib/maven3", "lib/maven3")
withResource("maven3-server-common/lib", "lib/maven3-server-lib")
withResource("maven2-server-impl/lib/maven2", "lib/maven2")
[
@@ -227,7 +227,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
Set<PluginId> dependentPlugins = new LinkedHashSet<>();
Set<PluginId> nonOptionalDependentPlugins = new LinkedHashSet<>();
if (pluginBean.dependencies != null) {
myOptionalConfigs = new THashMap<>();
myOptionalConfigs = new LinkedHashMap<>();
for (PluginDependency dependency : pluginBean.dependencies) {
String text = dependency.pluginId;
if (!StringUtil.isEmptyOrSpaces(text)) {
@@ -917,7 +917,7 @@ public class PluginManagerCore {
@NotNull Function<? super String, ? extends IdeaPluginDescriptorImpl> optionalDescriptorLoader) {
Map<PluginId, List<String>> optionalConfigs = descriptor.getOptionalConfigs();
if (optionalConfigs != null && !optionalConfigs.isEmpty()) {
Map<PluginId, List<IdeaPluginDescriptorImpl>> descriptors = new THashMap<>(optionalConfigs.size());
Map<PluginId, List<IdeaPluginDescriptorImpl>> descriptors = new LinkedHashMap<>(optionalConfigs.size());
for (Map.Entry<PluginId, List<String>> entry : optionalConfigs.entrySet()) {
for (String optionalDescriptorName : entry.getValue()) {
@@ -29,6 +29,7 @@ import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsColle
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -42,7 +43,7 @@ import java.util.List;
*
* @author Denis Zhdanov
*/
public class RefreshAllExternalProjectsAction extends AnAction implements AnAction.TransparentUpdate {
public class RefreshAllExternalProjectsAction extends AnAction implements AnAction.TransparentUpdate, DumbAware {
public RefreshAllExternalProjectsAction() {
getTemplatePresentation().setText(ExternalSystemBundle.message("action.refresh.all.projects.text", "external"));
@@ -15,6 +15,7 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.externalSystem.view.ExternalSystemNode;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -27,7 +28,7 @@ import java.util.List;
*
* @author Vladislav.Soroka
*/
public class RefreshExternalProjectAction extends ExternalSystemNodeAction<AbstractExternalEntityData> {
public class RefreshExternalProjectAction extends ExternalSystemNodeAction<AbstractExternalEntityData> implements DumbAware {
public RefreshExternalProjectAction() {
super(AbstractExternalEntityData.class);
@@ -156,8 +156,8 @@ public class NST {
return scrubberNativePeer;
}
public static ID createGroupItem(String uid, ID[] items, int count) {
return ourNSTLibrary.createGroupItem(uid, items, count); // called from AppKit, uses per-event autorelease-pool
public static ID createGroupItem(String uid, ID[] items) {
return ourNSTLibrary.createGroupItem(uid, items == null || items.length == 0 ? null : items, items.length); // called from AppKit, uses per-event autorelease-pool
}
public static void updateButton(ID buttonObj,
@@ -26,7 +26,7 @@ class TBItemGroup extends TBItem {
return ID.NIL;
final ID[] ids = myGroupItems.getVisibleNativePeers();
return NST.createGroupItem(myUid, ids, ids.length);
return NST.createGroupItem(myUid, ids);
}
@Override
@@ -2,6 +2,7 @@
package com.intellij.ide.plugins;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.util.lang.UrlClassLoader;
import org.junit.Test;
@@ -11,6 +12,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Set;
import static com.intellij.testFramework.UsefulTestCase.assertEmpty;
import static com.intellij.testFramework.UsefulTestCase.assertOneElement;
@@ -39,6 +41,17 @@ public class PluginDescriptorTest {
assertEquals(1, descriptor.getOptionalDescriptors().size());
}
@Test
public void testMultipleOptionalDescriptors() {
IdeaPluginDescriptorImpl descriptor = loadDescriptor("multipleOptionalDescriptors");
assertNotNull(descriptor);
Set<PluginId> ids = descriptor.getOptionalDescriptors().keySet();
assertEquals(2, ids.size());
PluginId[] idsArray = ids.toArray(PluginId.EMPTY_ARRAY);
assertEquals("dep2", idsArray[0].getIdString());
assertEquals("dep1", idsArray[1].getIdString());
}
@Test
public void testMalformedDescriptor() {
assertNull(loadDescriptor("malformed"));
@@ -207,12 +207,14 @@ add.dynamic.property=Add Dynamic Property ''{0}''
duplicate.element.in.the.map=Duplicate element ''{0}'' in the map
dynamic.tool.window.id=Dynamic Members
create.from.usage.family.name=Create From Usage
create.field.from.usage.family.name=Create field from usage
create.field.from.usage=Create field ''{0}''
create.method.from.usage.family.name=Create method from usage
create.method.from.usage=Create method ''{0}''
create.variable.from.usage.family.name=Create variable from usage
create.variable.from.usage=Create Variable ''{0}''
create.parameter.from.usage.family.name=Create parameter from usage
create.parameter.from.usage=Create parameter ''{0}''
add.dynamic.element=Add dynamic element
add.dynamic.method=Add Dynamic Method
dynamic.type=Type
@@ -288,7 +290,6 @@ ellipsis.type.is.not.allowed.here=Ellipsis type is not allowed here
method.0.is.too.complex.too.analyze=Method ''{0}'' is too complex to analyze.\nTypes of local variables are not inferred.
closure.is.too.complex.to.analyze=Closure is complex to analyze.\nTypes of local variables are not inferred.
0.is.deprecated=''{0}'' is deprecated
create.parameter.from.usage=Create parameter ''{0}''
wrong.number.of.type.arguments=Wrong number of type arguments\: {0}; required\: {1}
type.argument.0.is.not.in.its.bound.should.extend.1=Type parameter ''{0}'' is not in its bound; should extend ''{1}''
catch.statement.parameter.type.should.be.a.subclass.of.throwable=Catch statement parameter type should be a subclass of Throwable
@@ -6,13 +6,13 @@ import com.intellij.psi.PsiType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyReference;
import org.jetbrains.plugins.groovy.lang.resolve.api.GroovyCallReference;
public interface GrUnaryExpression extends GrExpression {
@NotNull
@Override
GroovyReference getReference();
GroovyCallReference getReference();
/**
* @return type of this expression with regard to whether this expression is prefix or postfix
@@ -9,11 +9,11 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyReference;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrExpressionImpl;
import org.jetbrains.plugins.groovy.lang.resolve.api.GroovyCallReference;
import org.jetbrains.plugins.groovy.lang.resolve.references.GrUnaryOperatorReference;
import org.jetbrains.plugins.groovy.lang.typing.GrTypeCalculator;
@@ -21,7 +21,7 @@ import java.util.Objects;
public class GrUnaryExpressionImpl extends GrExpressionImpl implements GrUnaryExpression {
private final GroovyReference myReference = new GrUnaryOperatorReference(this);
private final GroovyCallReference myReference = new GrUnaryOperatorReference(this);
public GrUnaryExpressionImpl(@NotNull ASTNode node) {
super(node);
@@ -29,7 +29,7 @@ public class GrUnaryExpressionImpl extends GrExpressionImpl implements GrUnaryEx
@NotNull
@Override
public GroovyReference getReference() {
public GroovyCallReference getReference() {
return myReference;
}
@@ -1,22 +1,10 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrOperatorExpression;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
@@ -32,9 +20,14 @@ public class GrBinaryExpressionUtil {
public static PsiType getDefaultNumericResultType(PsiType ltype, PsiType rtype, GrOperatorExpression e) {
int lRank = getTypeRank(ltype);
int rRank = getTypeRank(rtype);
return getDefaultNumericResultType(lRank, rRank, e);
}
@Nullable
public static PsiType getDefaultNumericResultType(int lRank, int rRank, PsiElement context) {
int resultRank = getResultTypeRank(lRank, rRank);
String fqn = getTypeFqn(resultRank);
return fqn == null ? null : createTypeByFQClassName(fqn, e);
return fqn == null ? null : createTypeByFQClassName(fqn, context);
}
private static int getResultTypeRank(int lRank, int rRank) {
@@ -7,6 +7,7 @@ import com.intellij.psi.*
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyMethodResult
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod
@@ -17,29 +18,35 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUt
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.getSmartReturnType
import org.jetbrains.plugins.groovy.lang.resolve.api.Argument
import org.jetbrains.plugins.groovy.lang.resolve.api.Arguments
import org.jetbrains.plugins.groovy.lang.resolve.impl.getArguments
class DefaultMethodCallTypeCalculator : GrTypeCalculator<GrMethodCall> {
override fun getType(expression: GrMethodCall): PsiType? {
val results = expression.multiResolve(false)
if (results.isEmpty()) {
return null
}
val arguments = expression.getArguments()
var type: PsiType? = null
for (result in expression.multiResolve(false)) {
type = TypesUtil.getLeastUpperBoundNullable(type, getTypeFromResult(result, expression), expression.manager)
for (result in results) {
type = TypesUtil.getLeastUpperBoundNullable(type, getTypeFromResult(result, arguments, expression), expression.manager)
}
return type
}
}
private fun getTypeFromResult(result: GroovyResolveResult, expression: GrMethodCall): PsiType? {
val baseType = getBaseTypeFromResult(result, expression).devoid(expression) ?: return null
fun getTypeFromResult(result: GroovyResolveResult, arguments: Arguments?, context: GrExpression): PsiType? {
val baseType = getBaseTypeFromResult(result, arguments, context).devoid(context) ?: return null
val substitutor = if (baseType !is GrLiteralClassType && hasGenerics(baseType)) result.substitutor else PsiSubstitutor.EMPTY
return TypesUtil.substituteAndNormalizeType(baseType, substitutor, result.spreadState, expression)
return TypesUtil.substituteAndNormalizeType(baseType, substitutor, result.spreadState, context)
}
private fun getBaseTypeFromResult(result: GroovyResolveResult, expression: GrMethodCall): PsiType? {
private fun getBaseTypeFromResult(result: GroovyResolveResult, arguments: Arguments?, context: PsiElement): PsiType? {
return when {
result.isInvokedOnProperty -> getTypeFromPropertyCall(result.element, expression)
result is GroovyMethodResult -> getTypeFromCandidate(result, expression)
result.isInvokedOnProperty -> getTypeFromPropertyCall(result.element, arguments, context)
result is GroovyMethodResult -> getTypeFromCandidate(result, context)
else -> null
}
}
@@ -54,7 +61,7 @@ private fun getTypeFromCandidate(result: GroovyMethodResult, context: PsiElement
private val ep: ExtensionPointName<GrCallTypeCalculator> = ExtensionPointName.create("org.intellij.groovy.callTypeCalculator")
private fun getTypeFromPropertyCall(element: PsiElement?, expression: GrMethodCall): PsiType? {
private fun getTypeFromPropertyCall(element: PsiElement?, arguments: Arguments?, context: PsiElement): PsiType? {
val type = when (element) { // TODO introduce property concept, resolve into it and get its type
is GrField -> element.typeGroovy
is GrMethod -> element.inferredReturnType
@@ -66,8 +73,8 @@ private fun getTypeFromPropertyCall(element: PsiElement?, expression: GrMethodCa
if (type !is GrClosureType) {
return null
}
val argumentTypes = expression.getArguments()?.map(Argument::type)?.toTypedArray()
return GrClosureSignatureUtil.getReturnType(type.signatures, argumentTypes, expression)
val argumentTypes = arguments?.map(Argument::type)?.toTypedArray()
return GrClosureSignatureUtil.getReturnType(type.signatures, argumentTypes, context)
}
fun PsiType?.devoid(context: PsiElement): PsiType? {
@@ -1,48 +1,25 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.typing
import com.intellij.psi.CommonClassNames.JAVA_LANG_NUMBER
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiType
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil.isNumericType
class DefaultUnaryExpressionTypeCalculator : GrTypeCalculator<GrUnaryExpression> {
override fun getType(expression: GrUnaryExpression): PsiType? {
val resolveResult = PsiImplUtil.extractUniqueResult(expression.reference.multiResolve(false))
if (isIncDecNumber(resolveResult)) {
return expression.operand?.type
}
val substituted = ResolveUtil.extractReturnTypeFromCandidate(resolveResult, expression, PsiType.EMPTY_ARRAY)
if (substituted != null) {
return substituted
}
val operand = expression.operand ?: return null
val type = operand.type
return if (TypesUtil.isNumericType(type)) type else null
return getTypeFromOperator(expression)
?: getNumericType(expression)
}
//hack for DGM.next(Number):Number
private fun isIncDecNumber(result: GroovyResolveResult): Boolean {
val element = result.element as? PsiMethod ?: return false
private fun getTypeFromOperator(expression: GrUnaryExpression): PsiType? {
val reference = expression.reference
val result = reference.advancedResolve()
return getTypeFromResult(result, reference.arguments, expression)
}
val method = (element as? GrGdkMethod)?.staticMethod ?: element
val name = method.name
if ("next" != name && "previous" != name) return false
if (!PsiUtil.isDGMMethod(method)) return false
val parameter = method.parameterList.parameters.singleOrNull() ?: return false
return parameter.type.equalsToText(JAVA_LANG_NUMBER)
private fun getNumericType(expression: GrUnaryExpression): PsiType? {
val type = expression.operand?.type
return if (isNumericType(type)) type else null
}
}
@@ -0,0 +1,39 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.typing
import com.intellij.psi.CommonClassNames
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiType
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypeConstants.INTEGER_RANK
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypeConstants.getTypeRank
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil.isNumericType
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionUtil.getDefaultNumericResultType
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.DEFAULT_GROOVY_METHODS
import org.jetbrains.plugins.groovy.lang.resolve.api.Arguments
class DgmNextPreviousCallTypeCalculator : GrCallTypeCalculator {
override fun getType(receiver: PsiType?, method: PsiMethod, arguments: Arguments?, context: PsiElement): PsiType? {
if (!isNextPrevious(method)) {
return null
}
val type = arguments?.firstOrNull()?.type
if (!isNumericType(type)) {
return null
}
return getDefaultNumericResultType(getTypeRank(type), INTEGER_RANK, context)
}
private fun isNextPrevious(method: PsiMethod): Boolean {
val name = method.name
if ("next" != name && "previous" != name) {
return false
}
if (method.containingClass?.qualifiedName != DEFAULT_GROOVY_METHODS) {
return false
}
val parameter = method.parameterList.parameters.singleOrNull() ?: return false
return parameter.type.equalsToText(CommonClassNames.JAVA_LANG_NUMBER)
}
}
+1
View File
@@ -156,6 +156,7 @@
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.WithTraitsTypeCalculator"/>
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.DgmCallTypeCalculator"/>
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.DgmIteratorCallTypeCalculator"/>
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.DgmNextPreviousCallTypeCalculator"/>
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.ClosureMethodsCallTypeCalculator"/>
<callTypeCalculator implementation="org.jetbrains.plugins.groovy.lang.typing.ObjectClassTypeCalculator"/>
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.annotator.intentions;
import com.intellij.codeInsight.generation.OverrideImplementUtil;
@@ -33,6 +33,12 @@ public class CreateMethodFromUsageFix extends GrCreateFromUsageBaseFix implement
super(refExpression);
}
@NotNull
@Override
public String getFamilyName() {
return GroovyBundle.message("create.method.from.usage.family.name");
}
@Override
@NotNull
public String getText() {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.annotator.intentions;
import com.intellij.ide.util.SuperMethodWarningUtil;
@@ -60,14 +46,14 @@ public class CreateParameterFromUsageFix extends Intention implements MethodOrCl
@NotNull
@Override
public String getText() {
return GroovyBundle.message("create.parameter.from.usage", myName);
public String getFamilyName() {
return GroovyBundle.message("create.parameter.from.usage.family.name");
}
@NotNull
@Override
public String getFamilyName() {
return GroovyBundle.message("create.from.usage.family.name");
public String getText() {
return GroovyBundle.message("create.parameter.from.usage", myName);
}
@Override
@@ -12,12 +12,9 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.psi.*;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyBundle;
import org.jetbrains.plugins.groovy.intentions.base.Intention;
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStaticChecker;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import javax.swing.*;
import java.util.ArrayList;
@@ -34,12 +31,6 @@ public abstract class GrCreateFromUsageBaseFix extends Intention {
myRefExpression = SmartPointerManager.getInstance(refExpression.getProject()).createSmartPsiElementPointer(refExpression);
}
@Override
@NotNull
public String getFamilyName() {
return GroovyBundle.message("create.from.usage.family.name");
}
protected GrReferenceExpression getRefExpr() {
return myRefExpression.getElement();
}
@@ -7,6 +7,8 @@ import org.jetbrains.plugins.groovy.util.GroovyLatestTest
import org.jetbrains.plugins.groovy.util.TypingTest
import org.junit.Test
import static com.intellij.psi.CommonClassNames.*
@CompileStatic
class TypeInsightTest extends GroovyLatestTest implements TypingTest {
@@ -21,4 +23,38 @@ class TypeInsightTest extends GroovyLatestTest implements TypingTest {
typingTest 'def usage(Map<String, Integer> m) { <caret>org.codehaus.groovy.runtime.DefaultGroovyMethods.iterator(m) }', GrMethodCall,
'java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Integer>>'
}
@Test
void 'number next previous'() {
expressionTypeTest '1.next()', JAVA_LANG_INTEGER
expressionTypeTest '((byte)1).next()', JAVA_LANG_INTEGER
expressionTypeTest '((short)1).next()', JAVA_LANG_INTEGER
expressionTypeTest '1l.next()', JAVA_LANG_LONG
expressionTypeTest '1f.next()', JAVA_LANG_DOUBLE
expressionTypeTest '1d.next()', JAVA_LANG_DOUBLE
expressionTypeTest '1.previous()', JAVA_LANG_INTEGER
expressionTypeTest '((byte)1).previous()', JAVA_LANG_INTEGER
expressionTypeTest '((short)1).previous()', JAVA_LANG_INTEGER
expressionTypeTest '1l.previous()', JAVA_LANG_LONG
expressionTypeTest '1f.previous()', JAVA_LANG_DOUBLE
expressionTypeTest '1d.previous()', JAVA_LANG_DOUBLE
}
@Test
void 'number inc dec'() {
expressionTypeTest '++1', JAVA_LANG_INTEGER
expressionTypeTest '++((byte)1)', JAVA_LANG_INTEGER
expressionTypeTest '++((short)1)', JAVA_LANG_INTEGER
expressionTypeTest '++1l', JAVA_LANG_LONG
expressionTypeTest '++1f', JAVA_LANG_DOUBLE
expressionTypeTest '++1d', JAVA_LANG_DOUBLE
expressionTypeTest '--1', JAVA_LANG_INTEGER
expressionTypeTest '--((byte)1)', JAVA_LANG_INTEGER
expressionTypeTest '--((short)1)', JAVA_LANG_INTEGER
expressionTypeTest '--1l', JAVA_LANG_LONG
expressionTypeTest '--1f', JAVA_LANG_DOUBLE
expressionTypeTest '--1d', JAVA_LANG_DOUBLE
}
}
@@ -1 +0,0 @@
lib/*
@@ -106,7 +106,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
if (pluginFileOrDir.isDirectory()) {
File parentFile = getMavenPluginParentFile();
myBundledMaven2Home = new File(parentFile, "maven2-server-impl/lib/maven2");
myBundledMaven3Home = new File(parentFile, "maven3-server-impl/lib/maven3");
myBundledMaven3Home = new File(parentFile, "maven36-server-impl/lib/maven3");
}
else {
myBundledMaven2Home = new File(root, "maven2");