Merge remote-tracking branch 'origin/master'

This commit is contained in:
irengrig
2015-04-15 16:23:09 +02:00
53 changed files with 873 additions and 180 deletions
+104
View File
@@ -0,0 +1,104 @@
target(nsis: 'Build nsis windows installer') {
nsis_installer()
}
String p(String key) {
return getProperty(key)
}
def nsis_installer(pathsToInclude, stringsFile, pathsFile, outNamePrefix, includeToolsJar = true, associateIpr = true,
system_selector = getProperty("system_selector"), failOnSignError = false, outFileName = null,
boolean hasBundledJRE = false) {
// p.s: Groovy reevaluates default value of system_selector on each call, so it always uses actual property value.
if (outFileName == null) {
outFileName = "${outNamePrefix}${buildNumber}"
}
ant.taskdef(name: "nsis", classname: "com.intellij.internalUtilities.ant.NsiFiles", classpath: "${home}/community/build/lib/NsiFiles.jar")
def box = paths.sandbox
ant.mkdir(dir: "$box/bin")
ant.mkdir(dir: "$box/nsiconf")
if (!hasBundledJRE) {
ant.mkdir(dir: "$box/jre")
requireProperty("jdk_bundled_win", "1.7")
def jdk_bundled_version = p("jdk_bundled_win") == "1.8" ? "${home}/build/jdk/jdk8_redist.zip" : "${home}/build/jdk/jdk_redist.zip"
ant.unzip(dest: "$box/jre", src: "${jdk_bundled_version}")
ant.copy(todir: "$box/bin") {
fileset(dir: "$box/jre/jre/bin") {
include(name: "msvcr71.dll")
}
}
}
ant.copy(todir: "$box/nsiconf") {
fileset(dir: "$home/community/build/conf/nsis") {
include(name: "*")
exclude(name: "version*")
exclude(name: "strings*")
exclude(name: "paths*")
}
}
if (isEap()) {
ant.copy(file: "$home/community/build/conf/nsis/version.eap.nsi",
tofile: "$box/nsiconf/version.nsi", overwrite: true)
}
else {
ant.copy(file: "$home/community/build/conf/nsis/version.nsi",
tofile: "$box/nsiconf/version.nsi", overwrite: true)
}
ant.copy(file: pathsFile, toFile: "$box/nsiconf/paths.nsi", overwrite: true)
ant.nsis(instfile: "$box/nsiconf/idea_win.nsh", uninstfile: "$box/nsiconf/unidea_win.nsh") {
pathsToInclude.each {
fileset(dir: it, includes: "**/*") {
exclude(name: "**/idea.properties")
exclude(name: "**/*.vmoptions")
}
}
fileset(dir: box, includes: "bin/msvcr71.dll")
if (!hasBundledJRE) {
fileset(dir: box, includes: "jre/**/*")
if (includeToolsJar) {
fileset(dir: box) {
include(name: "jre/lib/tools.jar")
}
}
}
}
ant.replace(file: "$stringsFile") {
replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
}
ant.copy(file: stringsFile, toFile: "$box/nsiconf/strings.nsi", overwrite: true)
ant.replace(file: "$box/nsiconf/version.nsi") {
replacefilter(token: "__BUILD_NUMBER__", value: buildNumber)
replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
replacefilter(token: "__MIN_UPGRADE_BUILD__", value: p("component.install-over.minbuild"))
replacefilter(token: "__MAX_UPGRADE_BUILD__", value: p("component.install-over.maxbuild"))
replacefilter(token: "__UPGRADE_VERSION__", value: p("component.install-over.version"))
replacefilter(token: "__PRODUCT_PATHS_SELECTOR__", value: system_selector)
}
ant.unzip(src: "$home/build/tools/NSIS.zip", dest: box)
ant.exec(command: "$box/NSIS/makensis.exe" +
" /DBASE_DIR=\"$home\"" +
" /DCOMMUNITY_DIR=\"$home/community\"" +
" /DIPR=\"${associateIpr}\"" +
" /DOUT_FILE=\"${outFileName}\"" +
" /DOUT_DIR=\"$paths.artifacts\"" +
" $box/nsiconf/idea.nsi")
projectBuilder.stage("Signing binaries")
executeExternalAnt(["dirName": "${paths.artifacts}", "fileName": "${outFileName}.exe"], "$home/build/signBuild.xml")
projectBuilder.stage("Signing done")
return "${paths.artifacts}/${outFileName}.exe"
}
@@ -45,6 +45,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.psi.JavaPsiFacade;
@@ -195,6 +196,11 @@ public abstract class JavaTestFrameworkRunnableState<T extends ModuleBasedConfig
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
configureClasspath(javaParameters);
if (!StringUtil.isEmptyOrSpaces(parameters)) {
javaParameters.getProgramParametersList().add("@name" + parameters);
}
return javaParameters;
}
@@ -331,7 +331,9 @@ public class SdkEditor implements Configurable, Place.Navigator {
}
sdkModificator = dummySdk.getSdkModificator();
for (OrderRootType type : myPathEditors.keySet()) {
myPathEditors.get(type).addPaths(sdkModificator.getRoots(type));
SdkPathEditor pathEditor = myPathEditors.get(type);
pathEditor.setAddBaseDir(dummySdk.getHomeDirectory());
pathEditor.addPaths(sdkModificator.getRoots(type));
}
mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
@@ -31,6 +32,7 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -43,7 +45,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.hash.HashSet;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,6 +53,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.ref.Reference;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -107,16 +109,17 @@ public class Java15APIUsageInspectionBase extends BaseJavaBatchLocalInspectionTo
return result;
}
private static void loadForbiddenApi(@NonNls String fileName, Set<String> set) {
private static void loadForbiddenApi(String fileName, Set<String> set) {
URL resource = Java15APIUsageInspectionBase.class.getResource(fileName);
if (resource == null) {
Logger.getInstance(Java15APIUsageInspectionBase.class).warn("not found: " + fileName);
return;
}
try {
Class<?> aClass = Java15APIUsageInspectionBase.class;
BufferedReader reader = new BufferedReader(new InputStreamReader(aClass.getResourceAsStream(fileName), CharsetToolkit.UTF8_CHARSET));
BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream(), CharsetToolkit.UTF8_CHARSET));
try {
do {
String line = reader.readLine();
if (line == null) break;
set.add(line);
} while(true);
set.addAll(FileUtil.loadLines(reader));
}
finally {
reader.close();
@@ -330,6 +333,7 @@ public class Java15APIUsageInspectionBase extends BaseJavaBatchLocalInspectionTo
private void registerError(PsiJavaCodeReferenceElement reference, LanguageLevel api) {
if (reference != null && isInProject(reference)) {
//noinspection DialogTitleCapitalization
myHolder.registerProblem(reference, InspectionsBundle.message("inspection.1.5.problem.descriptor", getShortName(api)));
}
}
@@ -382,7 +386,7 @@ public class Java15APIUsageInspectionBase extends BaseJavaBatchLocalInspectionTo
}
/**
* please leave public for {@link #com.intellij.codeInspection.JavaAPIUsagesInspectionTest#testCollectSinceApiUsages}
* please leave public for JavaAPIUsagesInspectionTest#testCollectSinceApiUsages
*/
@Nullable
public static String getSignature(@Nullable PsiMember member) {
@@ -21,6 +21,7 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.diff.FlyweightCapableTreeStructure;
import org.jetbrains.annotations.NotNull;
import java.util.AbstractList;
import java.util.List;
public class FCTSBackedLighterAST extends LighterAST {
@@ -55,4 +56,36 @@ public class FCTSBackedLighterAST extends LighterAST {
assert elements != null : myTreeStructure +" ("+parent+")";
return ContainerUtil.newArrayList(elements, 0, numKids);
}
public void disposeChildren(@NotNull List<LighterASTNode> children) {
if (children instanceof LighterASTNodeList) {
LighterASTNodeList nodes = (LighterASTNodeList)children;
myTreeStructure.disposeChildren(nodes.myElements, nodes.mySize);
} else {
LighterASTNode[] astNodes = new LighterASTNode[children.size()];
myTreeStructure.disposeChildren(children.toArray(astNodes), astNodes.length);
}
}
private static class LighterASTNodeList extends AbstractList<LighterASTNode> {
private final int mySize;
private final LighterASTNode[] myElements;
public LighterASTNodeList(int size, LighterASTNode[] elements) {
mySize = size;
myElements = elements;
}
@Override
public LighterASTNode get(final int index) {
if (index < 0 || index >= mySize) throw new IndexOutOfBoundsException("index:" + index + " size:" + mySize);
return myElements[index];
}
@Override
public int size() {
return mySize;
}
}
}
@@ -44,4 +44,6 @@ public abstract class LighterAST {
@NotNull
public abstract List<LighterASTNode> getChildren(@NotNull final LighterASTNode parent);
public abstract void disposeChildren(@NotNull List<LighterASTNode> children);
}
@@ -45,9 +45,8 @@ public class TreeBackedLighterAST extends LighterAST {
@Override
public List<LighterASTNode> getChildren(@NotNull final LighterASTNode parent) {
final ASTNode[] children = ((NodeWrapper)parent).myNode.getChildren(null);
if (children == null || children.length == 0) {
return ContainerUtil.emptyList();
}
if (children.length == 0) return ContainerUtil.emptyList();
List<LighterASTNode> result = new ArrayList<LighterASTNode>(children.length);
for (final ASTNode child : children) {
result.add(wrap(child));
@@ -55,6 +54,9 @@ public class TreeBackedLighterAST extends LighterAST {
return result;
}
public void disposeChildren(@NotNull List<LighterASTNode> children) {
}
@NotNull
private static LighterASTNode wrap(@NotNull ASTNode node) {
return node.getFirstChildNode() == null && node.getTextLength() > 0 ? new TokenNodeWrapper(node) : new NodeWrapper(node);
@@ -19,6 +19,8 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.PossiblyDumbAware;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.registry.RegistryValue;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.Stack;
@@ -38,7 +40,7 @@ import java.util.Set;
public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements PossiblyDumbAware {
private CustomFoldingProvider myDefaultProvider;
private static final int MAX_LOOKUP_DEPTH = 10;
private final RegistryValue myMaxLookupDepth = Registry.get("custom.folding.max.lookup.depth");
private static final ThreadLocal<Set<ASTNode>> ourCustomRegionElements = new ThreadLocal<Set<ASTNode>>();
@NotNull
@@ -103,7 +105,7 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements P
}
}
else {
if (currDepth < MAX_LOOKUP_DEPTH) {
if (currDepth < myMaxLookupDepth.asInteger()) {
addCustomFoldingRegionsRecursively(localFoldingStack, child, descriptors, currDepth + 1);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,11 +37,11 @@ class FakeRerunAction extends AnAction implements DumbAware {
if (environment != null) {
presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", environment.getRunProfile().getName()));
presentation.setIcon(ExecutionManagerImpl.isProcessRunning(getDescriptor(event)) ? AllIcons.Actions.Restart : environment.getExecutor().getIcon());
presentation.setEnabledAndVisible(isEnabled(event));
presentation.setEnabled(isEnabled(event));
return;
}
presentation.setEnabledAndVisible(false);
presentation.setEnabled(false);
}
@Override
@@ -35,6 +35,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
@@ -191,7 +192,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
}
}
private final class ShowExcludedFilesAction extends ToggleAction {
private final class ShowExcludedFilesAction extends ToggleAction implements DumbAware {
private ShowExcludedFilesAction() {
super(IdeBundle.message("action.show.excluded.files"), IdeBundle.message("action.show.hide.excluded.files"), null);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,8 @@ public class ListUtil {
boolean myIsEngaged = false;
public void mouseMoved(MouseEvent e) {
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e) && !(focusOwner instanceof JRootPane)) {
Point point = e.getPoint();
int index = list.locationToIndex(point);
list.putClientProperty(SELECTED_BY_MOUSE_EVENT, Boolean.TRUE);
@@ -45,6 +45,7 @@ import java.util.EventObject;
public class JBTable extends JTable implements ComponentWithEmptyText, ComponentWithExpandableItems<TableCell> {
public static final int PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS = 7;
public static final int COLUMN_RESIZE_AREA_WIDTH = 3; // same as in BasicTableHeaderUI
private static final int DEFAULT_MIN_COLUMN_WIDTH = 15; // see TableColumn constructor javadoc
private final StatusText myEmptyText;
private final ExpandableItemsHandler<TableCell> myExpandableItemsHandler;
@@ -794,27 +795,6 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
});
}
protected int getExpandedColumnWidth(int columnToExpand) {
int expandedWidth = getPreferredHeaderWidth(columnToExpand);
for (int row = 0; row < getRowCount(); row++) {
TableCellRenderer cellRenderer = getCellRenderer(row, columnToExpand);
if (cellRenderer != null) {
Component c = JBTable.this.prepareRenderer(cellRenderer, row, columnToExpand);
expandedWidth = Math.max(expandedWidth, c.getPreferredSize().width);
}
}
return expandedWidth;
}
private int getPreferredHeaderWidth(int columnIdx) {
TableColumn column = getColumnModel().getColumn(columnIdx);
TableCellRenderer renderer = column.getHeaderRenderer();
renderer = renderer == null ? getDefaultRenderer() : renderer;
Object headerValue = column.getHeaderValue();
Component headerCellRenderer = renderer.getTableCellRendererComponent(JBTable.this, headerValue, false, false, -1, columnIdx);
return headerCellRenderer.getPreferredSize().width;
}
private int getColumnToPack(Point p) {
int viewColumnIdx = JBTable.this.columnAtPoint(p);
if (viewColumnIdx == -1) return -1;
@@ -836,6 +816,33 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
}
}
public int getExpandedColumnWidth(int columnToExpand) {
int expandedWidth = getPreferredHeaderWidth(columnToExpand);
for (int row = 0; row < getRowCount(); row++) {
TableCellRenderer cellRenderer = getCellRenderer(row, columnToExpand);
if (cellRenderer != null) {
Component c = prepareRenderer(cellRenderer, row, columnToExpand);
expandedWidth = Math.max(expandedWidth, c.getPreferredSize().width);
}
}
return expandedWidth;
}
private int getPreferredHeaderWidth(int columnIdx) {
TableColumn column = getColumnModel().getColumn(columnIdx);
TableCellRenderer renderer = column.getHeaderRenderer();
if (renderer == null) {
JTableHeader header = getTableHeader();
if (header == null) {
return DEFAULT_MIN_COLUMN_WIDTH;
}
renderer = header.getDefaultRenderer();
}
Object headerValue = column.getHeaderValue();
Component headerCellRenderer = renderer.getTableCellRendererComponent(this, headerValue, false, false, -1, columnIdx);
return headerCellRenderer.getPreferredSize().width;
}
/**
* JTable gets table data from model lazily - only for a table part to be shown.
* JBTable loads <i>all</i> the data on initialization to calculate cell size.
@@ -124,7 +124,7 @@ public class StartupUtil {
if (!"true".equals(System.getProperty("idea.no.jre.check"))) {
try {
// try to find a class from tools.jar
Class.forName("com.sun.jdi.Field");
Class.forName("com.sun.jdi.Field", false, StartupUtil.class.getClassLoader());
}
catch (ClassNotFoundException e) {
String message = "'tools.jar' seems to be not in " + ApplicationNamesInfo.getInstance().getProductName() + " classpath.\n" +
@@ -132,6 +132,12 @@ public class StartupUtil {
Main.showMessage("JDK Required", message, true);
return false;
}
catch (LinkageError e) {
String message = "Cannot load a class from 'tools.jar': " + e.getMessage() + "\n" +
"Please ensure JAVA_HOME points to JDK rather than JRE.";
Main.showMessage("JDK Required", message, true);
return false;
}
if (StringUtil.containsIgnoreCase(System.getProperty("java.vm.name", ""), "OpenJDK") && !SystemInfo.isJavaVersionAtLeast("1.7")) {
String message = "OpenJDK 6 is not supported. Please use Oracle Java or newer OpenJDK.";
@@ -27,6 +27,7 @@ import com.intellij.ui.PopupHandler;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.speedSearch.ListWithFilter;
import com.intellij.ui.speedSearch.NameFilteringListModel;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
@@ -80,17 +81,44 @@ public class NewRecentProjectPanel extends RecentProjectPanel {
list.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
FlatWelcomeFrame frame = UIUtil.getParentOfType(FlatWelcomeFrame.class, list);
if (frame != null) {
FocusTraversalPolicy policy = frame.getFocusTraversalPolicy();
if (policy != null) {
Component next = policy.getComponentAfter(frame, list);
if (next != null) {
next.requestFocus();
Object selected = list.getSelectedValue();
final ProjectGroup group;
if (selected instanceof ProjectGroupActionGroup) {
group = ((ProjectGroupActionGroup)selected).getGroup();
} else {
group = null;
}
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_RIGHT) {
if (group != null) {
if (!group.isExpanded()) {
group.setExpanded(true);
ListModel model = ((NameFilteringListModel)list.getModel()).getOriginalModel();
int index = list.getSelectedIndex();
RecentProjectsWelcomeScreenActionBase.rebuildRecentProjectDataModel((DefaultListModel)model);
list.setSelectedIndex(group.getProjects().isEmpty() ? index : index + 1);
}
} else {
FlatWelcomeFrame frame = UIUtil.getParentOfType(FlatWelcomeFrame.class, list);
if (frame != null) {
FocusTraversalPolicy policy = frame.getFocusTraversalPolicy();
if (policy != null) {
Component next = policy.getComponentAfter(frame, list);
if (next != null) {
next.requestFocus();
}
}
}
}
} else if (keyCode == KeyEvent.VK_LEFT ) {
if (group != null && group.isExpanded()) {
group.setExpanded(false);
int index = list.getSelectedIndex();
ListModel model = ((NameFilteringListModel)list.getModel()).getOriginalModel();
RecentProjectsWelcomeScreenActionBase.rebuildRecentProjectDataModel((DefaultListModel)model);
list.setSelectedIndex(index);
}
}
}
});
@@ -186,7 +214,7 @@ public class NewRecentProjectPanel extends RecentProjectPanel {
return new JPanel() {
{
setLayout(new BorderLayout());
setBackground(UIUtil.getListBackground(isSelected));
setBackground(back);
boolean isGroup = value instanceof ProjectGroupActionGroup;
boolean isInsideGroup = false;
@@ -235,7 +235,8 @@ public class RecentProjectPanel extends JPanel {
boolean myIsEngaged = false;
@Override
public void mouseMoved(MouseEvent e) {
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e) && !(focusOwner instanceof JRootPane)) {
Point point = e.getPoint();
int index = myList.locationToIndex(point);
myList.setSelectedIndex(index);
@@ -35,7 +35,7 @@ import java.util.List;
*/
public abstract class RecentProjectsWelcomeScreenActionBase extends DumbAwareAction {
@Nullable
public DefaultListModel getDataModel(AnActionEvent e) {
public static DefaultListModel getDataModel(AnActionEvent e) {
final JList list = getList(e);
if (list != null) {
ListModel model = list.getModel();
@@ -50,7 +50,7 @@ public abstract class RecentProjectsWelcomeScreenActionBase extends DumbAwareAct
}
@NotNull
public List<AnAction> getSelectedElements(AnActionEvent e) {
public static List<AnAction> getSelectedElements(AnActionEvent e) {
final JList list = getList(e);
final List<AnAction> actions = new ArrayList<AnAction>();
if (list != null) {
@@ -64,7 +64,7 @@ public abstract class RecentProjectsWelcomeScreenActionBase extends DumbAwareAct
}
@Nullable
public JList getList(AnActionEvent e) {
public static JList getList(AnActionEvent e) {
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
if (component instanceof JList) {
return (JList)component;
@@ -72,7 +72,7 @@ public abstract class RecentProjectsWelcomeScreenActionBase extends DumbAwareAct
return null;
}
public boolean hasGroupSelected(AnActionEvent e) {
public static boolean hasGroupSelected(AnActionEvent e) {
for (AnAction action : getSelectedElements(e)) {
if (action instanceof ProjectGroupActionGroup) {
return true;
@@ -81,14 +81,18 @@ public abstract class RecentProjectsWelcomeScreenActionBase extends DumbAwareAct
return false;
}
public void rebuildRecentProjectsList(AnActionEvent e) {
public static void rebuildRecentProjectsList(AnActionEvent e) {
final DefaultListModel model = getDataModel(e);
if (model != null) {
model.clear();
for (AnAction action : RecentProjectsManager.getInstance().getRecentProjectsActions(false, FlatWelcomeFrame.isUseProjectGroups())) {
//noinspection unchecked
model.addElement(action);
}
rebuildRecentProjectDataModel(model);
}
}
public static void rebuildRecentProjectDataModel(@NotNull DefaultListModel model) {
model.clear();
for (AnAction action : RecentProjectsManager.getInstance().getRecentProjectsActions(false, FlatWelcomeFrame.isUseProjectGroups())) {
//noinspection unchecked
model.addElement(action);
}
}
}
@@ -555,7 +555,7 @@
</group>
<group id="WelcomeScreenRecentProjectActionGroup">
<action id="WelcomeScreen.OpenSelected" class="com.intellij.openapi.wm.impl.welcomeScreen.OpenSelectedProjectsAction"/>
<action id="WelcomeScreen.OpenSelected" class="com.intellij.openapi.wm.impl.welcomeScreen.OpenSelectedProjectsAction" text="Open Selected"/>
<action id="WelcomeScreen.NewGroup" class="com.intellij.openapi.wm.impl.welcomeScreen.CreateNewProjectGroupAction" text="New Project Group"/>
<group id="WelcomeScreen.MoveToGroup" class="com.intellij.openapi.wm.impl.welcomeScreen.MoveProjectToGroupActionGroup" text="Move To Group" popup="true"/>
</group>
@@ -28,6 +28,7 @@ import com.intellij.openapi.keymap.impl.ShortcutRestrictions;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.picocontainer.MutablePicoContainer;
@@ -208,6 +209,8 @@ public class ActionsTreeTest extends LightPlatformCodeInsightTestCase {
public void testPresentation() {
ActionManager manager = ActionManager.getInstance();
List<String> failures = new SmartList<String>();
for (String id : manager.getActionIds("")) {
if (!ACTION_WITHOUT_TEXT_AND_DESCRIPTION.equals(id)) {
try {
@@ -224,8 +227,8 @@ public class ActionsTreeTest extends LightPlatformCodeInsightTestCase {
if (action instanceof ActionGroup) {
System.out.println("ignored action group: " + message);
}
else {
assertFalse("no text: " + message, StringUtil.isEmpty(action.getTemplatePresentation().getText()));
else if (StringUtil.isEmpty(action.getTemplatePresentation().getText())) {
failures.add("no text: " + message);
}
}
catch (PluginException exception) {
@@ -233,6 +236,8 @@ public class ActionsTreeTest extends LightPlatformCodeInsightTestCase {
}
}
}
assertEmpty(failures);
}
private static void checkPresentationProperty(String name, String message, Object expected, Object actual) {
@@ -575,3 +575,6 @@ search.everywhere.pattern.checking.description=Avoid searching classes and symbo
idea.concurrent.scanning.files.to.index=true
welcome.screen.project.grouping.enabled=true
welcome.screen.project.grouping.enabled.description=Allows to group recent projects
custom.folding.max.lookup.depth=50
custom.folding.max.lookup.depth.description=Max lookup depth for custom folding comments in a PSI tree.
@@ -149,6 +149,9 @@
<localInspection groupPath="Java" language="JAVA" shortName="ArrayHashCode" bundle="com.siyeh.InspectionGadgetsBundle" key="array.hash.code.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
implementationClass="com.siyeh.ig.bugs.ArrayHashCodeInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="ArrayObjectsEquals" bundle="com.siyeh.InspectionGadgetsBundle"
key="array.objects.equals.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs"
enabledByDefault="true" level="WARNING" implementationClass="com.siyeh.ig.bugs.ArrayObjectsEqualsInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="AssertWithSideEffects" bundle="com.siyeh.InspectionGadgetsBundle"
key="assert.with.side.effects.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
@@ -2154,4 +2154,7 @@ dangling.javadoc.convert.quickfix=Replace with block comment
dangling.javadoc.delete.quickfix=Remove dangling comment
equals.replaceable.by.objects.call.display.name='equals()' expression replaceable by 'Objects.equals()' expression
equals.replaceable.by.objects.call.problem.descriptor=<code>#ref</code> replaceable by 'Objects.equals()' expression #loc
equals.replaceable.by.objects.call.quickfix=Replace with 'Objects.equals()' expression
equals.replaceable.by.objects.call.quickfix=Replace with 'Objects.equals()' expression
array.objects.equals.display.name='Objects.equals()' called on arrays
array.objects.equals.problem.descriptor=<code>Objects.#ref()</code> on arrays should probably be 'Arrays.equals()' #loc
array.objects.deep.equals.problem.descriptor=<code>Objects.#ref()</code> on arrays should probably be 'Arrays.deepEquals()' #loc
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 Dave Griffith, Bas Leijdekkers
* Copyright 2011-2015 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.
@@ -79,7 +79,7 @@ public class ArrayEqualityInspection extends BaseInspection {
@NotNull
@Override
public String getFamilyName() {
return "Replace with implicit equals";
return InspectionGadgetsBundle.message("replace.with.arrays.equals");
}
@Override
@@ -0,0 +1,149 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.ig.bugs;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.PsiReplacementUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Bas Leijdekkers
*/
public class ArrayObjectsEqualsInspection extends BaseInspection {
@Nls
@NotNull
@Override
public String getDisplayName() {
return InspectionGadgetsBundle.message("array.objects.equals.display.name");
}
@NotNull
@Override
protected String buildErrorString(Object... infos) {
final boolean deep = ((Boolean)infos[0]).booleanValue();
return deep
? InspectionGadgetsBundle.message("array.objects.deep.equals.problem.descriptor")
: InspectionGadgetsBundle.message("array.objects.equals.problem.descriptor");
}
@Override
public boolean isEnabledByDefault() {
return true;
}
@Nullable
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final boolean deep = ((Boolean)infos[0]).booleanValue();
return new ArrayObjectsEqualsFix(deep);
}
private static class ArrayObjectsEqualsFix extends InspectionGadgetsFix {
private final boolean myDeep;
public ArrayObjectsEqualsFix(boolean deep) {
myDeep = deep;
}
@Nls
@NotNull
@Override
public String getName() {
return myDeep ?
InspectionGadgetsBundle.message("replace.with.arrays.deep.equals") :
InspectionGadgetsBundle.message("replace.with.arrays.equals");
}
@NotNull
@Override
public String getFamilyName() {
return InspectionGadgetsBundle.message("replace.with.arrays.equals");
}
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement().getParent().getParent();
if (!(element instanceof PsiMethodCallExpression)) {
return;
}
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element;
final StringBuilder newExpression = new StringBuilder("java.util.Arrays.");
if (myDeep) {
newExpression.append("deepEquals");
}
else {
newExpression.append("equals");
}
newExpression.append(methodCallExpression.getArgumentList().getText());
PsiReplacementUtil.replaceExpressionAndShorten(methodCallExpression, newExpression.toString());
}
}
@Override
public BaseInspectionVisitor buildVisitor() {
return new ArrayObjectsEqualsVisitor();
}
private static class ArrayObjectsEqualsVisitor extends BaseInspectionVisitor {
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.EQUALS.equals(methodName)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] expressions = argumentList.getExpressions();
if (expressions.length != 2) {
return;
}
final PsiExpression argument1 = expressions[0];
final PsiType type1 = argument1.getType();
if (!(type1 instanceof PsiArrayType)) {
return;
}
final PsiExpression argument2 = expressions[1];
final PsiType type2 = argument2.getType();
if (!(type2 instanceof PsiArrayType)) {
return;
}
final int dimensions = type1.getArrayDimensions();
if (dimensions != type2.getArrayDimensions()) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null || !"java.util.Objects".equals(containingClass.getQualifiedName())) {
return;
}
registerMethodCallError(expression, Boolean.valueOf(dimensions > 1));
}
}
}
@@ -1,7 +1,7 @@
<html>
<body>
Reports any use of <b>==</b> to test for Array equality,
rather than the <b>"java.util.Arrays.equals()"</b> method.
Reports any use of <b>==</b> or <b>!=</b> to test for array equality,
rather than the <b>java.util.Arrays.equals()</b> method.
<!-- tooltip end -->
<p>
</body>
@@ -0,0 +1,11 @@
<html>
<body>
Reports <b>java.util.Objects.equals()</b> called on two arrays.
Calling <b>java.util.Objects.equals()</b> with array arguments compares identity and is equivalent to using <b>==</b>.
Use <b>Arrays.equals()</b> to compare the contents of two arrays
or <b>Arrays.deepEquals()</b> to compare the contents of two multi-dimensional arrays.
<!-- tooltip end -->
<p>
<small>New in 15</small>
</body>
</html>
@@ -1,7 +1,7 @@
<html>
<body>
Reports any use of <b>==</b> to test for Number equality,
rather than the <b>".equals()"</b> method. With auto-boxing it is easy
Reports any use of <b>==</b> or <b>!=</b> to test for Number equality,
rather than the <b>equals()</b> method. With auto-boxing it is easy
to make the mistake of comparing two Integer (or other subclass of java.lang.Number) objects instead
of two ints.
<!-- tooltip end -->
@@ -1,7 +1,7 @@
<html>
<body>
Reports any use of <b>==</b>
to test for Object equality, rather than the <b>".equals()"</b> method.
Reports any use of <b>==</b> or <b>!=</b>
to test for Object equality, rather than the <b>equals()</b> method.
Note that comparison of Strings or Numbers using <b>==</b> is not reported by this
inspection, nor is the comparison of an object to <b>null</b> using
<b>==</b>, or the comparison of two array objects.
@@ -1,7 +1,7 @@
<html>
<body>
Reports any use of <b>==</b> to test for String equality,
rather than the <b>".equals()"</b> method.
Reports any use of <b>==</b> or <b>!=</b> to test for String equality,
rather than the <b>equals()</b> method.
<!-- tooltip end -->
<p>
@@ -0,0 +1,14 @@
class ArrayObjectsEquals {
boolean one(String[] ss1, String[] ss2) {
return java.util.Objects.<warning descr="'Objects.equals()' on arrays should probably be 'Arrays.equals()'">equals</warning>(ss1, ss2);
}
boolean two(String[][] ss1, String[][] ss2) {
return java.util.Objects.<warning descr="'Objects.equals()' on arrays should probably be 'Arrays.deepEquals()'">equals</warning>(ss1, ss2);
}
boolean noWarn(String s1, String[] ss2) {
return java.util.Objects.equals(s1, ss2);
}
}
@@ -0,0 +1,47 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.ig.bugs;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import junit.framework.TestCase;
/**
* @author Bas Leijdekkers
*/
public class ArrayObjectsEqualsInspectionTest extends LightInspectionTestCase {
public void testArrayObjectsEquals() {
doTest();
}
@Override
protected InspectionProfileEntry getInspection() {
return new ArrayObjectsEqualsInspection();
}
@Override
protected String[] getEnvironmentClasses() {
return new String[]{
"package java.util;" +
"public class Objects {" +
" public static boolean equals(Object a, Object b) {" +
" return (a == b) || (a != null && a.equals(b));" +
" }" +
"}"
};
}
}
@@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsFileUtil;
import git4idea.GitUtil;
import git4idea.GitVcs;
import git4idea.branch.GitBranchUtil;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
@@ -57,22 +58,8 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
GitVcs vcs = GitVcs.getInstance(project);
final List<VirtualFile> roots = getGitRoots(project, vcs);
if (roots == null) return;
// get default root
final VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
VirtualFile defaultRootVar = null;
if (vFiles != null) {
for (VirtualFile file : vFiles) {
final VirtualFile root = GitUtil.gitRootOrNull(file);
if (root != null) {
defaultRootVar = root;
break;
}
}
}
if (defaultRootVar == null) {
defaultRootVar = roots.get(0);
}
final VirtualFile defaultRoot = defaultRootVar;
final VirtualFile defaultRoot = getDefaultRoot(project, roots, e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY));
final Set<VirtualFile> affectedRoots = new HashSet<VirtualFile>();
String actionName = getActionName();
@@ -88,6 +75,20 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
}
}
@NotNull
private static VirtualFile getDefaultRoot(@NotNull Project project, @NotNull List<VirtualFile> roots, @Nullable VirtualFile[] vFiles) {
if (vFiles != null) {
for (VirtualFile file : vFiles) {
VirtualFile root = GitUtil.gitRootOrNull(file);
if (root != null) {
return root;
}
}
}
GitRepository currentRepository = GitBranchUtil.getCurrentRepository(project);
return currentRepository != null ? currentRepository.getRoot() : roots.get(0);
}
protected final void runFinalTasks(Project project, GitVcs vcs, Set<VirtualFile> affectedRoots, String actionName,
List<VcsException> exceptions) {
VcsFileUtil.refreshFiles(project, affectedRoots);
@@ -21,14 +21,21 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.Cell;
import com.intellij.ui.TableSpeedSearch;
import com.intellij.ui.table.JBTable;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ListWithSelection;
import com.intellij.util.PairFunction;
import com.intellij.util.ui.ComboBoxTableCellRenderer;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import git4idea.GitUtil;
import git4idea.config.GitConfigUtil;
import git4idea.i18n.GitBundle;
import git4idea.util.StringScanner;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -53,7 +60,7 @@ public class GitRebaseEditor extends DialogWrapper {
/**
* The table that lists all commits
*/
private JTable myCommitsTable;
private JBTable myCommitsTable;
/**
* The move up button
*/
@@ -115,6 +122,7 @@ public class GitRebaseEditor extends DialogWrapper {
myTableModel.load(file);
myCommitsTable.setModel(myTableModel);
myCommitsTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
myCommitsTable.setIntercellSpacing(JBUI.emptySize());
final JComboBox editorComboBox = new JComboBox();
for (Object option : GitRebaseEntry.Action.values()) {
@@ -128,9 +136,9 @@ public class GitRebaseEditor extends DialogWrapper {
public void valueChanged(final ListSelectionEvent e) {
myViewButton.setEnabled(myCommitsTable.getSelectedRowCount() == 1);
final ListSelectionModel selectionModel = myCommitsTable.getSelectionModel();
myMoveUpButton.setEnabled( selectionModel.getMinSelectionIndex() > 0);
myMoveDownButton.setEnabled( selectionModel.getMaxSelectionIndex() != -1 &&
selectionModel.getMaxSelectionIndex() < myTableModel.myEntries.size() - 1);
myMoveUpButton.setEnabled(selectionModel.getMinSelectionIndex() > 0);
myMoveDownButton.setEnabled(selectionModel.getMaxSelectionIndex() != -1 &&
selectionModel.getMaxSelectionIndex() < myTableModel.myEntries.size() - 1);
}
});
myViewButton.addActionListener(new ActionListener() {
@@ -152,8 +160,37 @@ public class GitRebaseEditor extends DialogWrapper {
validateFields();
}
});
installSpeedSearch();
adjustColumnWidth(0);
adjustColumnWidth(1);
init();
}
private void installSpeedSearch() {
new TableSpeedSearch(myCommitsTable, new PairFunction<Object, Cell, String>() {
@Nullable
@Override
public String fun(Object o, Cell cell) {
return cell.column == 0 ? null : String.valueOf(o);
}
});
}
@Nullable
@Override
public JComponent getPreferredFocusedComponent() {
return myCommitsTable;
}
private void adjustColumnWidth(int columnIndex) {
int contentWidth = myCommitsTable.getExpandedColumnWidth(columnIndex) + UIUtil.DEFAULT_HGAP;
TableColumn column = myCommitsTable.getColumnModel().getColumn(columnIndex);
column.setMaxWidth(contentWidth);
column.setPreferredWidth(contentWidth);
}
/**
* Validate fields
*/
@@ -71,7 +71,7 @@ public class GroovyConsoleStateService implements PersistentStateComponent<Groov
final Entry e = new Entry();
e.url = file.getUrl();
e.moduleName = module == null ? "" : module.getName();
e.title = module == null ? "" : GroovyConsoleUtil.getTitle(module);
e.title = pair == null ? "" : pair.second;
result.list.add(e);
}
return result;
@@ -150,11 +150,6 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
javaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnitStarter.class));
String parameters = getConfiguration().getProgramParameters();
if (!StringUtil.isEmptyOrSpaces(parameters)) {
javaParameters.getProgramParametersList().add("@name" + parameters);
}
final StringBuilder buf = new StringBuilder();
collectListeners(javaParameters, buf, IDEAJUnitListener.EP_NAME, "\n");
if (buf.length() > 0) {
@@ -83,11 +83,11 @@ public class JUnitClasspathTest extends JavaCodeInsightFixtureTestCase {
String file = preparePathsForComparison(FileUtil.loadFile(workingDirsFile), mod1, mod2);
assertEquals("p\n" +
"MODULE_1\n" +
"IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/annotations.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/rt.jar\n" +
"IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.8/jre/lib/rt.jar\n" +
"1\n" +
"p.T1\n" +
"MODULE_2\n" +
"IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/annotations.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/rt.jar\n" +
"IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.8/jre/lib/rt.jar\n" +
"1\n" +
"p.T2\n", file);
@@ -99,11 +99,11 @@ public class JUnitClasspathTest extends JavaCodeInsightFixtureTestCase {
file = preparePathsForComparison(FileUtil.loadFile(workingDirsFile), mod1, mod2);
assertEquals("p\n" +
"MODULE_1\n" +
"IDEA_HOME/lib/serviceMessages.jar;IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/annotations.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/rt.jar\n" +
"IDEA_HOME/lib/serviceMessages.jar;IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.8/jre/lib/rt.jar\n" +
"1\n" +
"p.T1\n" +
"MODULE_2\n" +
"IDEA_HOME/lib/serviceMessages.jar;IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/annotations.jar;IDEA_HOME/java/mockJDK-1.7/jre/lib/rt.jar\n" +
"IDEA_HOME/lib/serviceMessages.jar;IDEA_HOME/lib/junit-4.12.jar;IDEA_HOME/java/mockJDK-1.8/jre/lib/rt.jar\n" +
"1\n" +
"p.T2\n", file);
}
@@ -133,7 +133,7 @@ public class JUnitClasspathTest extends JavaCodeInsightFixtureTestCase {
private Module setupModule(String moduleName, final String className) throws IOException {
final VirtualFile root1 = myFixture.getTempDirFixture().findOrCreateDir(moduleName);
final Module module = PsiTestUtil.addModule(getProject(), JavaModuleType.getModuleType(), moduleName, root1);
PsiTestUtil.removeAllRoots(module, IdeaTestUtil.getMockJdk17());
PsiTestUtil.removeAllRoots(module, IdeaTestUtil.getMockJdk18());
PsiTestUtil.addSourceRoot(module, root1, true);
myFixture.addFileToProject(moduleName + "/p/" + className + ".java",
"package p;\n" +
@@ -0,0 +1,119 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.lang.properties.editor;
import com.intellij.lang.properties.IProperty;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiTreeChangeAdapter;
import com.intellij.psi.PsiTreeChangeEvent;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* @author Dmitry Batkovich
*/
public class PropertiesAnchorizer {
private final static Logger LOG = Logger.getInstance(PropertiesAnchorizer.class);
private final Map<IProperty, PropertyAnchor> myAnchors = new HashMap<IProperty, PropertyAnchor>();
public PropertiesAnchorizer(Project project) {
PsiManager.getInstance(project).addPsiTreeChangeListener(new PsiTreeChangeAdapter() {
@Override
public void childRemoved(@NotNull PsiTreeChangeEvent event) {
final PsiElement removed = event.getChild();
if (removed instanceof IProperty) {
myAnchors.remove(removed);
}
}
});
}
public static final class PropertyAnchor {
private final Collection<IProperty> myProperties;
public PropertyAnchor(Collection<IProperty> properties) {
myProperties = new ArrayList<IProperty>(properties);
}
@NotNull
public String getName() {
return getRepresentative().getName();
}
@NotNull
public IProperty getRepresentative() {
return ContainerUtil.getFirstItem(myProperties);
}
@Override
public String toString() {
return "PropertyAnchor:" + getName();
}
private void addProperties(final Collection<IProperty> properties) {
myProperties.addAll(properties);
}
}
@NotNull
public PropertyAnchor get(IProperty property) {
final PropertyAnchor anchor = myAnchors.get(property);
LOG.assertTrue(anchor != null);
return anchor;
}
public PropertyAnchor createOrUpdate(final Collection<IProperty> properties) {
LOG.assertTrue(!properties.isEmpty());
final List<IProperty> propertiesWithoutAnchor = new SmartList<IProperty>();
PropertyAnchor representativeAnchor = null;
for (IProperty property : properties) {
final PropertyAnchor anchor = myAnchors.get(property);
if (anchor == null) {
propertiesWithoutAnchor.add(property);
} else {
if (representativeAnchor != null) {
LOG.assertTrue(representativeAnchor == anchor);
}
representativeAnchor = anchor;
}
}
if (representativeAnchor == null) {
LOG.assertTrue(propertiesWithoutAnchor.size() == properties.size());
representativeAnchor = new PropertyAnchor(properties);
} else {
representativeAnchor.addProperties(propertiesWithoutAnchor);
}
for (IProperty property : propertiesWithoutAnchor) {
myAnchors.put(property, representativeAnchor);
}
return representativeAnchor;
}
}
@@ -28,23 +28,23 @@ import com.intellij.navigation.ItemPresentation;
import com.intellij.psi.PsiElement;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import gnu.trove.TObjectIntHashMap;
import gnu.trove.TObjectIntProcedure;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class ResourceBundleFileStructureViewElement implements StructureViewTreeElement, ResourceBundleEditorViewElement {
private final ResourceBundle myResourceBundle;
private boolean myShowOnlyIncomplete;
private PropertiesAnchorizer myAnchorizer;
public ResourceBundleFileStructureViewElement(final ResourceBundle resourceBundle) {
public ResourceBundleFileStructureViewElement(final ResourceBundle resourceBundle, PropertiesAnchorizer anchorizer) {
myResourceBundle = resourceBundle;
myAnchorizer = anchorizer;
}
public void setShowOnlyIncomplete(boolean showOnlyIncomplete) {
@@ -62,50 +62,49 @@ public class ResourceBundleFileStructureViewElement implements StructureViewTree
@NotNull
public StructureViewTreeElement[] getChildren() {
final Map<String, IProperty> propertyNames = getPropertiesMap(myResourceBundle, myShowOnlyIncomplete);
final MultiMap<String, IProperty> propertyNames = getPropertiesMap(myResourceBundle, myShowOnlyIncomplete);
List<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(propertyNames.size());
for (IProperty property : propertyNames.values()) {
result.add(new ResourceBundlePropertyStructureViewElement(myResourceBundle, property));
for (Map.Entry<String, Collection<IProperty>> entry : propertyNames.entrySet()) {
final Collection<IProperty> properties = entry.getValue();
final PropertiesAnchorizer.PropertyAnchor anchor = myAnchorizer.createOrUpdate(properties);
result.add(new ResourceBundlePropertyStructureViewElement(myResourceBundle, anchor));
}
return result.toArray(new StructureViewTreeElement[result.size()]);
}
public static Map<String, IProperty> getPropertiesMap(ResourceBundle resourceBundle, boolean onlyIncomplete) {
public static MultiMap<String, IProperty> getPropertiesMap(ResourceBundle resourceBundle, boolean onlyIncomplete) {
List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
final Map<String, IProperty> propertyNames;
final MultiMap<String, IProperty> propertyNames;
if (onlyIncomplete) {
propertyNames = getChildrenIdShowOnlyIncomplete(resourceBundle);
} else {
propertyNames = new LinkedHashMap<String, IProperty>();
propertyNames = MultiMap.createLinked();
for (PropertiesFile propertiesFile : propertiesFiles) {
List<IProperty> properties = propertiesFile.getProperties();
for (IProperty property : properties) {
String name = property.getKey();
if (!propertyNames.containsKey(name)) {
propertyNames.put(name, property);
}
propertyNames.putValue(name, property);
}
}
}
return propertyNames;
}
private static Map<String, IProperty> getChildrenIdShowOnlyIncomplete(ResourceBundle resourceBundle) {
final Map<String, IProperty> propertyNames = new LinkedHashMap<String, IProperty>();
private static MultiMap<String, IProperty> getChildrenIdShowOnlyIncomplete(ResourceBundle resourceBundle) {
final MultiMap<String, IProperty> propertyNames = MultiMap.createLinked();
TObjectIntHashMap<String> occurrences = new TObjectIntHashMap<String>();
for (PropertiesFile file : resourceBundle.getPropertiesFiles()) {
Map<String, IProperty> currentFilePropertyNames = new LinkedHashMap<String, IProperty>();
MultiMap<String, IProperty> currentFilePropertyNames = MultiMap.createLinked();
for (IProperty property : file.getProperties()) {
String name = property.getKey();
if (!currentFilePropertyNames.containsKey(name)) {
currentFilePropertyNames.put(name, property);
}
currentFilePropertyNames.putValue(name, property);
}
propertyNames.putAll(currentFilePropertyNames);
propertyNames.putAllValues(currentFilePropertyNames);
for (String propertyName : currentFilePropertyNames.keySet()) {
if (occurrences.contains(propertyName)) {
occurrences.adjustValue(propertyName, 1);
} else {
}
else {
occurrences.put(propertyName, 1);
}
}
@@ -41,7 +41,7 @@ import java.awt.*;
public class ResourceBundlePropertyStructureViewElement implements StructureViewTreeElement, ResourceBundleEditorViewElement {
private final ResourceBundle myResourceBundle;
private final IProperty myProperty;
@NotNull private final PropertiesAnchorizer.PropertyAnchor myAnchor;
private String myPresentableName;
private static final TextAttributesKey INCOMPLETE_PROPERTY_KEY;
@@ -64,18 +64,18 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
INCOMPLETE_GROUP_KEY = TextAttributesKey.createTextAttributesKey("INCOMPLETE_GROUP_KEY", incompleteGroupKeyTextAttribute);
}
public ResourceBundlePropertyStructureViewElement(final ResourceBundle resourceBundle, final IProperty property) {
public ResourceBundlePropertyStructureViewElement(final ResourceBundle resourceBundle, final @NotNull PropertiesAnchorizer.PropertyAnchor anchor) {
myResourceBundle = resourceBundle;
myProperty = property;
myAnchor = anchor;
}
public IProperty getProperty() {
return myProperty;
return getValue().getRepresentative();
}
@Override
public PsiElement[] getPsiElements() {
return new PsiElement[] {getValue()};
return new PsiElement[] {getProperty().getPsiElement()};
}
public void setPresentableName(final String presentableName) {
@@ -83,8 +83,8 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
}
@Override
public PsiElement getValue() {
return myProperty.getPsiElement();
public PropertiesAnchorizer.PropertyAnchor getValue() {
return myAnchor;
}
@Override
@@ -99,7 +99,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
return myPresentableName == null ? myProperty.getName() : myPresentableName.isEmpty() ? PROPERTY_GROUP_KEY_TEXT : myPresentableName;
return myPresentableName == null ? getProperty().getName() : myPresentableName.isEmpty() ? PROPERTY_GROUP_KEY_TEXT : myPresentableName;
}
@Override
@@ -115,11 +115,11 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
@Override
public TextAttributesKey getTextAttributesKey() {
if (myPresentableName != null && myPresentableName.isEmpty()) {
return PropertiesUtil.isPropertyComplete(myResourceBundle, myProperty.getName())
return PropertiesUtil.isPropertyComplete(myResourceBundle, getProperty().getName())
? GROUP_KEY
: INCOMPLETE_GROUP_KEY;
}
return PropertiesUtil.isPropertyComplete(myResourceBundle, myProperty.getName())
return PropertiesUtil.isPropertyComplete(myResourceBundle, getProperty().getName())
? PropertiesHighlighter.PROPERTY_KEY
: INCOMPLETE_PROPERTY_KEY;
}
@@ -35,12 +35,12 @@ public class ResourceBundleStructureViewModel implements PropertiesGroupingStruc
private final GroupByWordPrefixes myByWordPrefixesGrouper;
private final ResourceBundleFileStructureViewElement myRoot;
public ResourceBundleStructureViewModel(ResourceBundle root) {
public ResourceBundleStructureViewModel(ResourceBundle root, PropertiesAnchorizer anchorizer) {
myResourceBundle = root;
String separator = PropertiesSeparatorManager.getInstance(root.getProject()).
getSeparator(myResourceBundle);
myByWordPrefixesGrouper = new GroupByWordPrefixes(separator);
myRoot = new ResourceBundleFileStructureViewElement(myResourceBundle);
myRoot = new ResourceBundleFileStructureViewElement(myResourceBundle, anchorizer);
}
public void setSeparator(String separator) {
@@ -21,6 +21,7 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.smartTree.*;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.PropertiesBundle;
import com.intellij.lang.properties.editor.PropertiesAnchorizer;
import com.intellij.lang.properties.editor.ResourceBundlePropertyStructureViewElement;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
@@ -69,7 +70,10 @@ public class GroupByWordPrefixes implements Grouper, Sorter {
if (!(element instanceof StructureViewTreeElement)) {
continue;
}
final Object value = ((StructureViewTreeElement)element).getValue();
Object value = ((StructureViewTreeElement)element).getValue();
if (value instanceof PropertiesAnchorizer.PropertyAnchor) {
value = ((PropertiesAnchorizer.PropertyAnchor)value).getRepresentative();
}
if (!(value instanceof IProperty)) {
continue;
}
@@ -182,6 +186,11 @@ public class GroupByWordPrefixes implements Grouper, Sorter {
this.words = words;
this.node = node;
}
@Override
public String toString() {
return "Key{words=" + words + ", node=" + node + '}';
}
}
}
@@ -20,6 +20,7 @@ import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.util.treeView.smartTree.Group;
import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.editor.PropertiesAnchorizer;
import com.intellij.lang.properties.editor.ResourceBundleEditorViewElement;
import com.intellij.lang.properties.editor.ResourceBundlePropertyStructureViewElement;
import com.intellij.lang.properties.psi.Property;
@@ -95,7 +96,10 @@ public class PropertiesPrefixGroup implements Group, ResourceBundleEditorViewEle
if (!(treeElement instanceof StructureViewTreeElement)) {
continue;
}
final Object value = ((StructureViewTreeElement)treeElement).getValue();
Object value = ((StructureViewTreeElement)treeElement).getValue();
if (value instanceof PropertiesAnchorizer.PropertyAnchor) {
value = ((PropertiesAnchorizer.PropertyAnchor)value).getRepresentative();
}
if (!(value instanceof IProperty)) {
continue;
}
@@ -105,6 +105,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
// we cannot store it back to properties file right now, so just append the backslash to the editor and wait for the subsequent chars
private final Set<PropertiesFile> myBackSlashPressed = new THashSet<PropertiesFile>();
private final Alarm mySelectionChangeAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private final PropertiesAnchorizer myPropertiesAnchorizer;
private JPanel myValuesPanel;
private JPanel myStructureViewPanel;
@@ -131,7 +132,8 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
myResourceBundle = resourceBundle;
myPropertiesInsertDeleteManager = ResourceBundlePropertiesInsertManagerImpl.create(resourceBundle);
myStructureViewComponent = new ResourceBundleStructureViewComponent(myResourceBundle, this);
myPropertiesAnchorizer = new PropertiesAnchorizer(myResourceBundle.getProject());
myStructureViewComponent = new ResourceBundleStructureViewComponent(myResourceBundle, this, myPropertiesAnchorizer);
myStructureViewPanel.setLayout(new BorderLayout());
myStructureViewPanel.add(myStructureViewComponent, BorderLayout.CENTER);
@@ -284,10 +286,11 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
while (!toCheck.isEmpty()) {
TreeElement element = toCheck.pop();
PsiElement value = element instanceof ResourceBundlePropertyStructureViewElement
? ((ResourceBundlePropertyStructureViewElement)element).getValue()
? ((ResourceBundlePropertyStructureViewElement)element).getProperty().getPsiElement()
: null;
if (value instanceof IProperty && propertyName.equals(((IProperty)value).getUnescapedKey())) {
myStructureViewComponent.select(value, true);
final PropertiesAnchorizer.PropertyAnchor anchor = myPropertiesAnchorizer.get((IProperty)value);
myStructureViewComponent.select(anchor, true);
selectionChanged();
return;
}
@@ -361,7 +364,6 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
}
}
});
}
});
}
@@ -596,11 +598,11 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
@Override
public void childrenChanged(@NotNull PsiTreeChangeEvent event) {
final PsiFile file = event.getFile();
PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
if (propertiesFile == null) return;
if (!propertiesFile.getResourceBundle().equals(myResourceBundle)) return;
updateEditorsFromProperties();
// final PsiFile file = event.getFile();
//PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
//if (propertiesFile == null) return;
//if (!propertiesFile.getResourceBundle().equals(myResourceBundle)) return;
//updateEditorsFromProperties();
}
};
PsiManager.getInstance(myProject).addPsiTreeChangeListener(psiTreeChangeAdapter, this);
@@ -693,10 +695,9 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
final ResourceBundleFileStructureViewElement root =
(ResourceBundleFileStructureViewElement)myStructureViewComponent.getTreeModel().getRoot();
final Map<String, IProperty> propertiesMap =
ResourceBundleFileStructureViewElement.getPropertiesMap(myResourceBundle, root.isShowOnlyIncomplete());
final Set<String> propertyKeys = ResourceBundleFileStructureViewElement.getPropertiesMap(myResourceBundle, root.isShowOnlyIncomplete()).keySet();
final boolean isAlphaSorted = myStructureViewComponent.isActionActive(Sorter.ALPHA_SORTER_ID);
final List<String> keysOrder = new ArrayList<String>(propertiesMap.keySet());
final List<String> keysOrder = new ArrayList<String>(propertyKeys);
if (isAlphaSorted) {
Collections.sort(keysOrder);
}
@@ -53,8 +53,10 @@ public class ResourceBundleStructureViewComponent extends PropertiesGroupingStru
private final ResourceBundle myResourceBundle;
public ResourceBundleStructureViewComponent(final ResourceBundle resourceBundle, final ResourceBundleEditor editor) {
super(resourceBundle.getProject(), editor, new ResourceBundleStructureViewModel(resourceBundle));
public ResourceBundleStructureViewComponent(final ResourceBundle resourceBundle,
final ResourceBundleEditor editor,
final PropertiesAnchorizer anchorizer) {
super(resourceBundle.getProject(), editor, new ResourceBundleStructureViewModel(resourceBundle, anchorizer));
myResourceBundle = resourceBundle;
tunePopupActionGroup();
}
@@ -20,21 +20,20 @@
*/
package com.theoryinpractice.testng.configuration;
import com.intellij.execution.*;
import com.intellij.execution.JavaExecutionUtil;
import com.intellij.execution.Location;
import com.intellij.execution.RunManager;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.actions.ConfigurationContext;
import com.intellij.execution.actions.RunConfigurationProducer;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.impl.RunManagerImpl;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.execution.junit.JavaRunConfigurationProducerBase;
import com.intellij.execution.junit.JavaRuntimeConfigurationProducerBase;
import com.intellij.execution.junit2.PsiMemberParameterizedLocation;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.*;
import com.intellij.psi.PsiElement;
import com.theoryinpractice.testng.model.TestData;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import org.testng.IDEATestNGRemoteListener;
public abstract class TestNGConfigurationProducer extends JavaRunConfigurationProducerBase<TestNGConfiguration> implements Cloneable {
@@ -48,13 +47,17 @@ public abstract class TestNGConfigurationProducer extends JavaRunConfigurationPr
return false;
}
final RunConfiguration predefinedConfiguration = context.getOriginalConfiguration(TestNGConfigurationType.getInstance());
Location location = JavaExecutionUtil.stepIntoSingleClass(context.getLocation());
final Location contextLocation = context.getLocation();
Location location = JavaExecutionUtil.stepIntoSingleClass(contextLocation);
final PsiElement element = location.getPsiElement();
RunnerAndConfigurationSettings template = RunManager.getInstance(location.getProject()).getConfigurationTemplate(getConfigurationFactory());
final Module predefinedModule = ((TestNGConfiguration)template.getConfiguration()).getConfigurationModule().getModule();
final String vmParameters =
predefinedConfiguration instanceof TestNGConfiguration ? ((TestNGConfiguration)predefinedConfiguration).getVMParameters() : null;
if (vmParameters != null && !Comparing.strEqual(vmParameters, testNGConfiguration.getVMParameters())) return false;
String paramSetName = contextLocation instanceof PsiMemberParameterizedLocation
? getInvocationNumber(((PsiMemberParameterizedLocation)contextLocation).getParamSetName()) : null;
if (paramSetName != null && !Comparing.strEqual(paramSetName, testNGConfiguration.getProgramParameters())) return false;
TestData testobject = testNGConfiguration.getPersistantData();
if (testobject != null) {
if (testobject.isConfiguredByElement(element)) {
@@ -65,4 +68,15 @@ public abstract class TestNGConfigurationProducer extends JavaRunConfigurationPr
}
return false;
}
protected static String getInvocationNumber(String str) {
final int indexOf = str.indexOf(IDEATestNGRemoteListener.INVOCATION_NUMBER);
if (indexOf > 0) {
final int lastIdx = str.indexOf(")", indexOf);
if (lastIdx > 0) {
return str.substring(indexOf + IDEATestNGRemoteListener.INVOCATION_NUMBER.length(), lastIdx);
}
}
return null;
}
}
@@ -20,12 +20,14 @@
*/
package com.theoryinpractice.testng.configuration;
import com.intellij.execution.Location;
import com.intellij.execution.PsiLocation;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.actions.ConfigurationContext;
import com.intellij.execution.actions.ConfigurationFromContext;
import com.intellij.execution.actions.RunConfigurationProducer;
import com.intellij.execution.junit.InheritorChooser;
import com.intellij.execution.junit2.PsiMemberParameterizedLocation;
import com.intellij.execution.junit2.info.MethodLocation;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
@@ -100,6 +102,14 @@ public class TestNGInClassConfigurationProducer extends TestNGConfigurationProdu
return false;
}
final Location contextLocation = context.getLocation();
if (contextLocation instanceof PsiMemberParameterizedLocation) {
final String paramSetName = getInvocationNumber(((PsiMemberParameterizedLocation)contextLocation).getParamSetName());
if (paramSetName != null) {
configuration.setProgramParameters(paramSetName);
}
}
PsiClass psiClass = null;
PsiElement element = context.getPsiLocation();
while (element != null) {
@@ -19,14 +19,21 @@ package org.testng;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;
import org.testng.collections.Lists;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlInclude;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class IDEARemoteTestNG extends TestNG {
private final String myParam;
public IDEARemoteTestNG(String param) {
myParam = param;
}
private static void calculateAllSuites(List<XmlSuite> suites, List<XmlSuite> outSuites) {
for (XmlSuite s : suites) {
outSuites.add(s);
@@ -50,6 +57,12 @@ public class IDEARemoteTestNG extends TestNG {
for (XmlTest test : tests) {
for (XmlClass aClass : test.getXmlClasses()) {
System.out.println("##teamcity[suiteTreeStarted name=\'" + aClass.getName() + "\' locationHint=\'java:suite://" + aClass.getName() + "\']");
if (myParam != null) {
for (XmlInclude include : aClass.getIncludedMethods()) {
aClass.setIncludedMethods(Arrays.asList(new XmlInclude(include.getName(), Arrays.asList(Integer.parseInt(myParam)), 0)));
}
}
System.out.println("##teamcity[suiteTreeEnded name=\'" + aClass.getName() + "\']");
}
testCount += test.getClasses().size();
@@ -60,8 +73,8 @@ public class IDEARemoteTestNG extends TestNG {
final HashMap<String, String> map = new HashMap<String, String>();
map.put("count", String.valueOf(testCount));
System.out.println(ServiceMessage.asString("testCount", map));
addListener((ISuiteListener) new IDEATestNGRemoteListener());
addListener((ITestListener) new IDEATestNGRemoteListener());
addListener((ISuiteListener) new IDEATestNGRemoteListener(myParam));
addListener((ITestListener) new IDEATestNGRemoteListener(myParam));
super.run();
}
else {
@@ -15,7 +15,15 @@ import java.util.Map;
*/
public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener{
public static final String INVOCATION_NUMBER = "invocation number: ";
private final String myParam;
private String myCurrentClassName;
private String myMethodName;
private int myInvocationCount = 0;
public IDEATestNGRemoteListener(String param) {
myParam = param;
}
public void onConfigurationSuccess(ITestResult itr) {
//won't be called
@@ -46,17 +54,31 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
}
System.out.println("##teamcity[testSuiteStarted name =\'" + className + "\']");
myCurrentClassName = className;
myInvocationCount = 0;
}
String methodName = getMethodName(result);
String methodName = getMethodName(result, false);
System.out.println("##teamcity[testStarted name=\'" +
methodName + "\' locationHint=\'java:test://" + className + "." + methodName + "\']");
}
private static String getMethodName(ITestResult result) {
private String getMethodName(ITestResult result) {
return getMethodName(result, true);
}
private String getMethodName(ITestResult result, boolean changeCount) {
String methodName = result.getMethod().getMethodName();
final Object[] parameters = result.getParameters();
if (changeCount) {
if (!methodName.equals(myMethodName)) {
myInvocationCount = 0;
myMethodName = methodName;
}
}
if (parameters.length > 0) {
methodName += "[" + parameters[0].toString() + "]";
methodName += "[" + parameters[0].toString() + (myParam == null ? (" (" + INVOCATION_NUMBER + myInvocationCount + ")") : "") + "]";
if (changeCount) {
myInvocationCount++;
}
}
return methodName;
}
@@ -77,13 +99,14 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
final Throwable ex = result.getThrowable();
final String trace = getTrace(ex);
final Map<String, String> attrs = new HashMap<String, String>();
attrs.put("name", getMethodName(result));
final String methodName = getMethodName(result);
attrs.put("name", methodName);
final String failureMessage = ex.getMessage();
attrs.put("message", failureMessage != null ? failureMessage : "");
attrs.put("details", trace);
attrs.put("error", "true");
System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs));
System.out.println("##teamcity[testFinished name=\'" + getMethodName(result) + "\']");
System.out.println("##teamcity[testFinished name=\'" + methodName + "\']");
}
public void onTestSkipped(ITestResult result) {
@@ -38,10 +38,14 @@ public class RemoteTestNGStarter {
private static final String SOCKET = "-socket";
public static void main(String[] args) throws Exception {
int i = 0;
String param = null;
Vector resultArgs = new Vector();
for (; i < args.length; i++) {
String arg = args[i];
if (arg.startsWith(SOCKET)) {
if (arg.startsWith("@name")) {
param = arg.substring(5);
continue;
} else if (arg.startsWith(SOCKET)) {
final int port = Integer.parseInt(arg.substring(SOCKET.length()));
try {
final Socket socket = new Socket(InetAddress.getByName("127.0.0.1"), port); //start collecting tests
@@ -95,7 +99,7 @@ public class RemoteTestNGStarter {
}
if (SM_RUNNER) {
final IDEARemoteTestNG testNG = new IDEARemoteTestNG();
final IDEARemoteTestNG testNG = new IDEARemoteTestNG(param);
CommandLineArgs cla = new CommandLineArgs();
RemoteArgs ra = new RemoteArgs();
new JCommander(Arrays.asList(cla, ra), (String[])resultArgs.toArray(new String[resultArgs.size()]));
+12
View File
@@ -76,4 +76,16 @@
<option name="PATTERN" value="org.springsource.loaded.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="javassist.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="org.apache.webbeans.*" />
<option name="ENABLED" value="true" />
</filter>
<filter>
<option name="PATTERN" value="com.ibm.ws.*" />
<option name="ENABLED" value="true" />
</filter>
</component>
@@ -25,6 +25,8 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlText;
import com.intellij.psi.xml.XmlToken;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.spellchecker.inspections.PlainTextSplitter;
import com.intellij.spellchecker.inspections.TextSplitter;
import com.intellij.spellchecker.quickfixes.AcceptWordAsCorrect;
@@ -71,6 +73,9 @@ public class SpellcheckingStrategy {
}
return TEXT_TOKENIZER;
}
if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
return TEXT_TOKENIZER;
}
return EMPTY_TOKENIZER;
}
@@ -0,0 +1,3 @@
<a>test</a>
<TYPO descr="Typo: In word 'ttest'">ttest</TYPO>
<div>test</div>
@@ -27,4 +27,8 @@ public class XmlWithMistakesInspectionTest extends SpellcheckerInspectionTestCas
public void testXml() {
doTest("test.xml");
}
public void testCharacterData() {
doTest("test.html");
}
}
@@ -52,7 +52,7 @@ public class DomExtenderEP extends AbstractExtensionPointBean {
}
catch (Exception e) {
LOG.error(e);
return null;
return registrar;
}
}
@@ -67,7 +67,7 @@ public class DomExtenderEP extends AbstractExtensionPointBean {
}
catch (Exception e) {
LOG.error(e);
return null;
return registrar;
}
}