Merge remote-tracking branch 'origin/master'

This commit is contained in:
Kirill Likhodedov
2012-05-12 17:28:05 +04:00
12 changed files with 149 additions and 36 deletions
+1
View File
@@ -10602,6 +10602,7 @@ gutter/overridingMethod.png:/lib/icons.jar
gutter/implementingMethod.png:/lib/icons.jar
gutter/overridenMethod.png:/lib/icons.jar
gutter/implementedMethod.png:/lib/icons.jar
gutter/recursiveMethod.png:/lib/icons.jar
com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl$1.class:/lib/idea.jar
com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.class:/lib/idea.jar
com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider$1.class:/lib/idea.jar
@@ -643,7 +643,8 @@ public class CompileServerManager implements ApplicationComponent{
cmdLine.addParameter("-classpath");
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
cp.add(ClasspathBootstrap.getResourcePath(systemCompiler.getClass())); // tools.jar
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
cmdLine.addParameter(classpathToString(cp));
@@ -565,14 +565,10 @@ public class BuildManager implements ApplicationComponent{
}
private Process launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException {
// validate tools.jar presence
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
if (systemCompiler == null) {
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
}
// choosing sdk with which the build process should be run
Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
Sdk projectJdk = internalJdk;
final String versionString = projectJdk.getVersionString();
if (versionString != null) {
JavaSdkVersion sdkVersion = ((JavaSdk)projectJdk.getSdkType()).getVersion(versionString);
@@ -600,6 +596,23 @@ public class BuildManager implements ApplicationComponent{
}
}
// validate tools.jar presence
final File compilerPath;
if (projectJdk.equals(internalJdk)) {
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
if (systemCompiler == null) {
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
}
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
}
else {
final String path = ((JavaSdk)projectJdk.getSdkType()).getToolsPath(projectJdk);
if (path == null) {
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
}
compilerPath = new File(path);
}
final GeneralCommandLine cmdLine = new GeneralCommandLine();
final String vmExecutablePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk);
cmdLine.setExePath(vmExecutablePath);
@@ -667,7 +680,8 @@ public class BuildManager implements ApplicationComponent{
cmdLine.addParameter("-classpath");
final List<File> cp = ClasspathBootstrap.getCompileServerApplicationClasspath();
final List<File> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath();
cp.add(compilerPath);
cp.addAll(myClasspathManager.getCompileServerPluginsClasspath());
cmdLine.addParameter(classpathToString(cp));
@@ -32,6 +32,7 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.AllOverridingMethodsSearch;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
@@ -60,6 +61,8 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
private static final Icon IMPLEMENTED_INTERFACE_MARKER_RENDERER = IMPLEMENTED_METHOD_MARKER_RENDERER;
private static final Icon SUBCLASSED_CLASS_MARKER_RENDERER = OVERRIDEN_METHOD_MARKER_RENDERER;
private static final Icon RECURSIVE_METHOD_ICON = IconLoader.getIcon("/gutter/recursiveMethod.png");
protected final DaemonCodeAnalyzerSettings myDaemonSettings;
protected final EditorColorsManager myColorsManager;
@@ -164,6 +167,11 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
}
else if (element instanceof PsiClass && !(element instanceof PsiTypeParameter)) {
collectInheritingClasses((PsiClass)element, result);
} else if(element instanceof PsiMethodCallExpression){
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
if (isRecursiveMethodCall(methodCall)){
result.add(new RecursiveMethodCallMarkerInfo(methodCall));
}
}
}
if (!methods.isEmpty()) {
@@ -171,6 +179,16 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
}
}
private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){
final PsiMethod referencedMethod = (PsiMethod)methodCall.getMethodExpression().resolve();
if (referencedMethod == null){
return false;
}
return referencedMethod.getTextRange().contains(methodCall.getTextRange());
}
private static void collectInheritingClasses(PsiClass aClass, Collection<LineMarkerInfo> result) {
if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
@@ -276,4 +294,36 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
};
}
}
private static class RecursiveMethodCallMarkerInfo extends MergeableLineMarkerInfo<PsiMethodCallExpression> {
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) {
super(methodCall,
methodCall.getTextRange(),
RECURSIVE_METHOD_ICON,
Pass.UPDATE_OVERRIDEN_MARKERS,
FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive call"),
null,
GutterIconRenderer.Alignment.RIGHT
);
}
@Override
public boolean canMergeWith(@NotNull MergeableLineMarkerInfo<?> info) {
if (!(info instanceof RecursiveMethodCallMarkerInfo)) return false;
PsiElement otherElement = info.getElement();
PsiElement myElement = getElement();
return otherElement != null && myElement != null;
}
@Override
public Icon getCommonIcon(@NotNull List<MergeableLineMarkerInfo> infos) {
return myIcon;
}
@Override
public Function<? super PsiElement, String> getCommonTooltip(@NotNull List<MergeableLineMarkerInfo> infos) {
return FunctionUtil.<PsiElement, String>constant("Multiple recursive calls");
}
}
}
@@ -168,11 +168,12 @@ final class BuildSession implements Runnable, CanceledStatus {
final Project project = loadProject(projectPath);
final File dataStorageRoot = Utils.getDataStorageRoot(project);
final boolean inMemoryMappingsDelta = System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null;
ProjectTimestamps projectTimestamps = null;
BuildDataManager dataManager = null;
try {
projectTimestamps = new ProjectTimestamps(dataStorageRoot);
dataManager = new BuildDataManager(dataStorageRoot, true);
dataManager = new BuildDataManager(dataStorageRoot, inMemoryMappingsDelta);
if (dataManager.versionDiffers()) {
forceCleanCaches = true;
msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Dependency data format has changed, project rebuild required"));
@@ -190,7 +191,7 @@ final class BuildSession implements Runnable, CanceledStatus {
forceCleanCaches = true;
FileUtil.delete(dataStorageRoot);
projectTimestamps = new ProjectTimestamps(dataStorageRoot);
dataManager = new BuildDataManager(dataStorageRoot, true);
dataManager = new BuildDataManager(dataStorageRoot, inMemoryMappingsDelta);
// second attempt succeded
msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Project rebuild forced: " + e.getMessage()));
}
@@ -86,7 +86,7 @@ public class ClasspathBootstrap {
private ClasspathBootstrap() {
}
public static List<File> getCompileServerApplicationClasspath() {
public static List<File> getBuildProcessApplicationClasspath() {
final Set<File> cp = new LinkedHashSet<File>();
cp.add(getResourcePath(Server.class));
for (String path : PathManager.getUtilClassPath()) { cp.add(new File(path)); } // util
@@ -114,14 +114,6 @@ public class ClasspathBootstrap {
catch (Throwable ignored) {
}
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
if (systemCompiler != null) {
try {
cp.add(getResourcePath(systemCompiler.getClass())); // tools.jar
}
catch (Throwable ignored) {
}
}
return new ArrayList<File>(cp);
}
@@ -33,6 +33,10 @@ public abstract class AbstractExtensionPointBean implements PluginAware {
myPluginDescriptor = pluginDescriptor;
}
public PluginDescriptor getPluginDescriptor() {
return myPluginDescriptor;
}
@NotNull
public final <T> Class<T> findClass(final String className) throws ClassNotFoundException {
return (Class<T>)Class.forName(className, true, getLoaderForClass());
Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -263,13 +263,13 @@ public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyle
final TableColumn levelColumn = treeTable.getColumnModel().getColumn(1);
//TODO[max]: better preffered size...
JLabel value = new JLabel(ApplicationBundle.message("option.table.sizing.text"));
final Dimension valueSize = value.getPreferredSize();
levelColumn.setPreferredWidth(valueSize.width);
levelColumn.setMaxWidth(valueSize.width);
levelColumn.setMinWidth(valueSize.width);
levelColumn.setResizable(false);
//TODO[kb]: Did I fixed it by making the last column floating?
//levelColumn.setPreferredWidth(valueSize.width);
//levelColumn.setMaxWidth(valueSize.width);
//levelColumn.setMinWidth(valueSize.width);
//levelColumn.setResizable(false);
final Dimension valueSize = new JLabel(ApplicationBundle.message("option.table.sizing.text")).getPreferredSize();
treeTable.setPreferredScrollableViewportSize(new Dimension(maxWidth + valueSize.width + 10, 20));
return treeTable;
@@ -519,7 +519,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
if (!isEditing()) {
return;
}
Component c = myFocusManager.getFocusOwner();
Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
while (c != null) {
if (c instanceof JPopupMenu) {
c = ((JPopupMenu)c).getInvoker();
@@ -3,13 +3,20 @@
*/
package com.intellij.psi.tree;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageExtensionPoint;
import com.intellij.lang.ParserDefinition;
import com.intellij.lang.PsiParser;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import gnu.trove.THashMap;
import gnu.trove.TObjectIntHashMap;
import java.util.Arrays;
import java.util.Comparator;
/**
* @author gregsh
@@ -20,28 +27,74 @@ public class IElementTypeTest extends LightPlatformCodeInsightFixtureTestCase {
@SuppressWarnings("UnusedDeclaration")
public void testCount() throws Exception {
int count = IElementType.getAllocatedTypesCount();
System.out.println("Before: " + count +" types");
System.out.println("Preloaded: " + count +" element types");
LanguageExtensionPoint[] extensions = Extensions.getExtensions(new ExtensionPointName<LanguageExtensionPoint>("com.intellij.lang.parserDefinition"));
System.out.println(extensions.length +" definitions");
System.out.println("ParserDefinitions: " + extensions.length);
THashMap<Language, String> languageMap = new THashMap<Language, String>();
languageMap.put(Language.ANY, "platform");
final TObjectIntHashMap<String> map = new TObjectIntHashMap<String>();
for (LanguageExtensionPoint e : extensions) {
String key = e.getPluginDescriptor().getPluginId().getIdString();
int curCount = IElementType.getAllocatedTypesCount();
ParserDefinition definition = (ParserDefinition)e.getInstance();
IFileElementType type = definition.getFileNodeType();
Language language = type.getLanguage();
languageMap.put(language, key);
if (language.getBaseLanguage() != null && !languageMap.containsKey(language.getBaseLanguage())) {
languageMap.put(language.getBaseLanguage(), key);
}
try {
IFileElementType type = definition.getFileNodeType();
Lexer lexer = definition.createLexer(getProject());
PsiParser parser = definition.createParser(getProject());
}
catch (UnsupportedOperationException e1) {
}
// language-based calculation: per-class-loading stuff commented
//int diff = IElementType.getAllocatedTypesCount() - curCount;
//map.put(key, map.get(key) + diff);
}
System.out.println("After: " + IElementType.getAllocatedTypesCount() +" types");
// language-based calculation
count = IElementType.getAllocatedTypesCount();
for (short i = 0; i < count; i ++ ) {
IElementType type = IElementType.find(i);
Language language = type.getLanguage();
String key = null;
for (Language cur = language; cur != null && key == null; cur = cur.getBaseLanguage()) {
key = languageMap.get(cur);
}
key = StringUtil.notNullize(key, "unknown");
map.put(key, map.get(key) + 1);
//if (key.equals("unknown")) System.out.println(type +" " + language);
}
System.out.println("Total: " + IElementType.getAllocatedTypesCount() +" element types");
// Show per-plugin statistics
Object[] keys = map.keys();
Arrays.sort(keys, new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
return map.get((String)o2) - map.get((String)o1);
}
});
int sum = 0;
for (Object key : keys) {
int value = map.get((String)key);
if (value == 0) continue;
sum += value;
System.out.println(" " + key + ": " + value);
}
// leave some index-space for plugin developers
assertTrue(IElementType.getAllocatedTypesCount() < 10000);
assertEquals(IElementType.getAllocatedTypesCount(), sum);
// output on 11.05.2012
// Before: 3485 types
// Preloaded: 3485 types
// 95 definitions
// After: 7694 types
// Total: 7694 types
}
}
@@ -30,8 +30,5 @@ public class LanguageInjectionConfigBean extends AbstractExtensionPointBean {
return myConfigUrl;
}
public PluginDescriptor getPluginDescriptor() {
return myPluginDescriptor;
}
}