Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master' into develar/is
  • Loading branch information
develar committed Jul 21, 2016
2 parents 36fe649 + e1d4d1a commit e7648df
Show file tree
Hide file tree
Showing 293 changed files with 2,957 additions and 1,832 deletions.
2 changes: 1 addition & 1 deletion bin/scripts/win/idea.bat
Expand Up @@ -29,7 +29,7 @@ IF EXIST "%USER_JDK64_FILE%" (
IF EXIST "%USER_JDK_FILE%" SET /P JDK=<%USER_JDK_FILE%
)
IF NOT "%JDK%" == "" (
IF NOT EXIST "%JDK%" SET JDK=%IDE_HOME%\%JDK%
IF NOT EXIST "%JDK%" SET JDK="%IDE_HOME%\%JDK%"
GOTO check
)

Expand Down
File renamed without changes.
Expand Up @@ -26,6 +26,7 @@ class IdeaCommunityProperties extends ProductProperties {
applicationInfoModule = "community-resources"
additionalIDEPropertiesFilePaths = ["$home/build/conf/ideaCE.properties"]
toolsJarRequired = true
buildCrossPlatformDistribution = true
}

@Override
Expand All @@ -39,6 +40,9 @@ class IdeaCommunityProperties extends ProductProperties {
fileset(file: "$buildContext.paths.communityHome/LICENSE.txt")
fileset(file: "$buildContext.paths.communityHome/NOTICE.txt")
}
buildContext.ant.copy(todir: "$targetDirectory/bin") {
fileset(dir: "$buildContext.paths.communityHome/build/conf/ideaCE/common/bin")
}
}

@Override
Expand Down
Expand Up @@ -65,6 +65,11 @@ public abstract class ProductProperties {
*/
abstract String systemSelector(ApplicationInfoProperties applicationInfo)

/**
* If {@code true} cross-platform ZIP archive containing binaries for all OS will be built
*/
boolean buildCrossPlatformDistribution = false

/**
* Paths to properties files the content of which should be appended to idea.properties file
*/
Expand Down
Expand Up @@ -231,14 +231,16 @@ idea.fatal.error.notification=disabled
}
}

if (windowsBuilder != null && linuxBuilder != null && macBuilder != null) {
buildContext.executeStep("Build cross-platform distribution", BuildOptions.CROSS_PLATFORM_DISTRIBUTION_STEP) {
def crossPlatformBuilder = new CrossPlatformDistributionBuilder(buildContext)
crossPlatformBuilder.buildCrossPlatformZip(windowsBuilder.winDistPath, linuxBuilder.unixDistPath, macBuilder.macDistPath)
if (buildContext.productProperties.buildCrossPlatformDistribution) {
if (windowsBuilder != null && linuxBuilder != null && macBuilder != null) {
buildContext.executeStep("Build cross-platform distribution", BuildOptions.CROSS_PLATFORM_DISTRIBUTION_STEP) {
def crossPlatformBuilder = new CrossPlatformDistributionBuilder(buildContext)
crossPlatformBuilder.buildCrossPlatformZip(windowsBuilder.winDistPath, linuxBuilder.unixDistPath, macBuilder.macDistPath)
}
}
else {
buildContext.messages.info("Skipping building cross-platform distribution because some OS-specific distributions were skipped")
}
}
else {
buildContext.messages.info("Skipping building cross-platform distribution because some OS-specific distributions was skipeed")
}
}

Expand Down
Expand Up @@ -36,10 +36,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.*;

public class CompoundPositionManager extends PositionManagerEx implements MultiRequestPositionManager{
private static final Logger LOG = Logger.getInstance(CompoundPositionManager.class);
Expand All @@ -57,9 +54,10 @@ public CompoundPositionManager(PositionManager manager) {
public void appendPositionManager(PositionManager manager) {
myPositionManagers.remove(manager);
myPositionManagers.add(0, manager);
mySourcePositionCache.clear();
}

private final Cache<Location, SourcePosition> mySourcePositionCache = new Cache<>();
private final Map<Location, SourcePosition> mySourcePositionCache = new WeakHashMap<>();

private interface Processor<T> {
T process(PositionManager positionManager) throws NoDataException;
Expand Down Expand Up @@ -196,21 +194,4 @@ public ThreeState evaluateCondition(@NotNull EvaluationContext context,
}
return ThreeState.UNSURE;
}

private static class Cache<K,V> {
private K myKey;
private V myValue;

public V get(@NotNull K key) {
if (key.equals(myKey)) {
return myValue;
}
return null;
}

public void put(@NotNull K key, V value) {
myKey = key;
myValue = value;
}
}
}
Expand Up @@ -85,7 +85,7 @@ public SdkSettingsStep(WizardContext context,
sdkFilter = JdkComboBox.getSdkFilter(sdkTypeIdFilter);
}

myJdkComboBox = new JdkComboBox(myModel, sdkFilter, sdkTypeIdFilter, true);
myJdkComboBox = new JdkComboBox(myModel, sdkTypeIdFilter, sdkFilter, sdkTypeIdFilter, true);
myJdkPanel = new JPanel(new GridBagLayout());

final PropertiesComponent component = project == null ? PropertiesComponent.getInstance() : PropertiesComponent.getInstance(project);
Expand Down
Expand Up @@ -66,14 +66,15 @@ public JdkComboBox(@NotNull final ProjectSdksModel jdkModel) {

public JdkComboBox(@NotNull final ProjectSdksModel jdkModel,
@Nullable Condition<SdkTypeId> filter) {
this(jdkModel, getSdkFilter(filter), filter, false);
this(jdkModel, filter, getSdkFilter(filter), filter, false);
}

public JdkComboBox(@NotNull final ProjectSdksModel jdkModel,
@Nullable Condition<SdkTypeId> sdkTypeFilter,
@Nullable Condition<Sdk> filter,
@Nullable Condition<SdkTypeId> creationFilter,
boolean addSuggestedItems) {
super(new JdkComboBoxModel(jdkModel, filter, addSuggestedItems));
super(new JdkComboBoxModel(jdkModel, sdkTypeFilter, filter, addSuggestedItems));
myFilter = filter;
myCreationFilter = creationFilter;
setRenderer(new ProjectJdkListRenderer() {
Expand Down Expand Up @@ -289,7 +290,8 @@ public void reloadModel(JdkComboBoxItem firstItem, @Nullable Project project) {
}

private static class JdkComboBoxModel extends DefaultComboBoxModel {
public JdkComboBoxModel(final ProjectSdksModel jdksModel, @Nullable Condition<Sdk> sdkFilter, boolean addSuggested) {
public JdkComboBoxModel(final ProjectSdksModel jdksModel, @Nullable Condition<SdkTypeId> sdkTypeFilter,
@Nullable Condition<Sdk> sdkFilter, boolean addSuggested) {
Sdk[] jdks = jdksModel.getSdks();
Arrays.sort(jdks, (s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()));
for (Sdk jdk : jdks) {
Expand All @@ -298,14 +300,14 @@ public JdkComboBoxModel(final ProjectSdksModel jdksModel, @Nullable Condition<Sd
}
}
if (addSuggested) {
addSuggestedItems(sdkFilter, jdks);
addSuggestedItems(sdkTypeFilter, jdks);
}
}

protected void addSuggestedItems(@Nullable Condition<Sdk> sdkFilter, Sdk[] jdks) {
protected void addSuggestedItems(@Nullable Condition<SdkTypeId> sdkTypeFilter, Sdk[] jdks) {
SdkType[] types = SdkType.getAllTypes();
for (SdkType type : types) {
if (sdkFilter == null || ContainerUtil.find(jdks, sdkFilter) == null) {
if (sdkTypeFilter == null || sdkTypeFilter.value(type) && ContainerUtil.find(jdks, sdk -> sdk.getSdkType() == type) == null) {
String homePath = type.suggestHomePath();
if (homePath != null && type.isValidSdkHome(homePath)) {
addElement(new SuggestedJdkItem(type, homePath));
Expand Down
Expand Up @@ -272,5 +272,9 @@ public abstract IntentionAction createAddMissingRequiredAnnotationParametersFix(
@NotNull
public abstract IntentionAction createWrapWithOptionalFix(@Nullable PsiType type, @NotNull PsiExpression expression);

public abstract IntentionAction createNotIterableForEachLoopFix(PsiExpression expression);
@Nullable
public abstract IntentionAction createNotIterableForEachLoopFix(@NotNull PsiExpression expression);

@NotNull
public abstract List<IntentionAction> createAddAnnotationAttributeNameFixes(@NotNull PsiNameValuePair pair);
}
Expand Up @@ -33,6 +33,7 @@
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.impl.source.PsiImmediateClassType;
import com.intellij.psi.util.ClassUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
Expand Down Expand Up @@ -72,7 +73,12 @@ static HighlightInfo checkNameValuePair(PsiNameValuePair pair) {
else {
String description = JavaErrorMessages.message("annotation.missing.method", ref.getCanonicalText());
PsiElement element = ref.getElement();
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
final HighlightInfo highlightInfo =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
for (IntentionAction action : QuickFixFactory.getInstance().createAddAnnotationAttributeNameFixes(pair)) {
QuickFixAction.registerQuickFixAction(highlightInfo, action);
}
return highlightInfo;
}
}
else {
Expand Down Expand Up @@ -152,7 +158,7 @@ static HighlightInfo checkMemberValueType(@Nullable PsiAnnotationMemberValue val
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
if (psiClass != null && psiClass.isEnum() && !(expr instanceof PsiReferenceExpression && ((PsiReferenceExpression)expr).resolve() instanceof PsiEnumConstant)) {
String description = JavaErrorMessages.message("annotation.non.enum.constant.attribute.value");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
}

if (type != null && TypeConversionUtil.areTypesAssignmentCompatible(expectedType, expr) ||
Expand Down Expand Up @@ -749,7 +755,7 @@ static HighlightInfo checkReceiverType(PsiReceiverParameter parameter) {

private static boolean isStatic(PsiModifierListOwner owner) {
if (owner == null) return false;
if (owner instanceof PsiClass && ((PsiClass)owner).getContainingClass() == null) return true;
if (owner instanceof PsiClass && ClassUtil.isTopLevelClass((PsiClass)owner)) return true;
PsiModifierList modifierList = owner.getModifierList();
return modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC);
}
Expand Down
Expand Up @@ -16,7 +16,6 @@
package com.intellij.codeInsight.intention;

import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
import com.intellij.codeInspection.IntentionAndQuickFixAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
Expand Down Expand Up @@ -627,8 +626,15 @@ public IntentionAction createWrapWithOptionalFix(@Nullable PsiType type, @NotNul
return QuickFixes.EMPTY_FIX;
}

@Nullable
@Override
public IntentionAction createNotIterableForEachLoopFix(PsiExpression expression) {
public IntentionAction createNotIterableForEachLoopFix(@NotNull PsiExpression expression) {
return QuickFixes.EMPTY_FIX;
}

@NotNull
@Override
public List<IntentionAction> createAddAnnotationAttributeNameFixes(@NotNull PsiNameValuePair pair) {
return Collections.emptyList();
}
}
Expand Up @@ -78,9 +78,14 @@ public PsiField[] findDeclaredFields(@NotNull final PsiManager manager, @NotNull
@Override
@NotNull
public PsiMethod[] findDeclaredMethods(@NotNull final PsiManager manager, @NotNull String name) {
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
return cache.getMethodsByNameIfNotMoreThan(name, scope, MAX_COUNT);
Project project = manager.getProject();
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
GlobalSearchScope sources = GlobalSearchScope.projectScope(project);
GlobalSearchScope libraries = GlobalSearchScope.notScope(sources);
PsiMethod[] sourceMethods = cache.getMethodsByNameIfNotMoreThan(name, sources, MAX_COUNT);
if (sourceMethods.length == MAX_COUNT) return sourceMethods;
PsiMethod[] libraryMethods = cache.getMethodsByNameIfNotMoreThan(name, libraries, MAX_COUNT-sourceMethods.length);
return ArrayUtil.mergeArrays(sourceMethods, libraryMethods);
}
};
private static final PsiType[] PRIMITIVE_TYPES = {PsiType.BYTE, PsiType.CHAR, PsiType.SHORT, PsiType.INT, PsiType.LONG, PsiType.FLOAT, PsiType.DOUBLE};
Expand Down Expand Up @@ -1274,9 +1279,11 @@ private ExpectedTypeInfo[] findClassesWithDeclaredField(@NotNull PsiReferenceExp
* By default searches in the global scope (see ourGlobalScopeClassProvider), but caller can provide its own algorithm e.g. to narrow search scope
*/
public interface ExpectedClassProvider {
PsiField[] findDeclaredFields(final PsiManager manager, String name);
@NotNull
PsiField[] findDeclaredFields(@NotNull PsiManager manager, @NotNull String name);

PsiMethod[] findDeclaredMethods(final PsiManager manager, String name);
@NotNull
PsiMethod[] findDeclaredMethods(@NotNull PsiManager manager, @NotNull String name);
}

@NotNull
Expand Down
@@ -0,0 +1,77 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon;

import com.intellij.codeHighlighting.RainbowHighlighter;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightVisitor;
import com.intellij.ide.highlighter.JavaHighlightingColors;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class JavaRainbowVisitor extends RainbowVisitor {
@Override
public boolean suitableForFile(@NotNull PsiFile file) {
return file instanceof PsiJavaFile;
}

@Override
public void visit(@NotNull PsiElement element) {
if (!RainbowHighlighter.isRainbowEnabled()) return;

if (element instanceof PsiReferenceExpression
|| element instanceof PsiLocalVariable
|| element instanceof PsiParameter) {
PsiElement context = PsiTreeUtil.findFirstParent(element, p -> p instanceof PsiMethod);
if (context != null) {
HighlightInfo attrs = getRainbowSymbolKey(
context,
element instanceof PsiReferenceExpression
? Pair.create(element, ((PsiReferenceExpression)element).resolve())
: Pair.create(((PsiVariable)element).getNameIdentifier(), element));
if (attrs != null) {
addInfo(attrs);
}
}
}
}

@Nullable
private HighlightInfo getRainbowSymbolKey(@NotNull PsiElement context, @NotNull Pair<PsiElement, PsiElement> rainbow) {
if (rainbow.first == null || rainbow.second == null) {
return null;
}
if (rainbow.second instanceof PsiLocalVariable || rainbow.second instanceof PsiParameter) {
String name = ((PsiVariable)rainbow.second).getName();
if (name != null) {
return getInfo(context, rainbow.first, name, rainbow.second instanceof PsiLocalVariable
? JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES
: JavaHighlightingColors.PARAMETER_ATTRIBUTES);
}
}
return null;
}

@Override
@NotNull
public HighlightVisitor clone() {
return new JavaRainbowVisitor();
}
}

0 comments on commit e7648df

Please sign in to comment.