mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+12
-6
@@ -37,15 +37,13 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.treeStructure.actions.CollapseAllAction;
|
||||
@@ -826,7 +824,15 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
|
||||
modificationCountForChildren = ourSettingsModificationCount;
|
||||
}
|
||||
|
||||
final long currentStamp = myProject != null ? PsiManager.getInstance(myProject).getModificationTracker().getModificationCount() : -1;
|
||||
final Object o = unwrapValue(getValue());
|
||||
long currentStamp = -1;
|
||||
if (o instanceof StubBasedPsiElement && ((StubBasedPsiElement)o).getStub() != null) {
|
||||
currentStamp = ((StubBasedPsiElement)o).getContainingFile().getModificationStamp();
|
||||
} else if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement) {
|
||||
currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount();
|
||||
} else if (o instanceof ModificationTracker) {
|
||||
currentStamp = ((ModificationTracker)o).getModificationCount();
|
||||
}
|
||||
if (childrenStamp != currentStamp) {
|
||||
resetChildren();
|
||||
childrenStamp = currentStamp;
|
||||
|
||||
+7
-2
@@ -81,7 +81,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
public static final String DISPLAY_NAME = "Inspections";
|
||||
private static final String HEADER_TITLE = "Profile:";
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + InspectionToolsConfigurable.class.getName());
|
||||
private static final Logger LOG = Logger.getInstance(InspectionToolsConfigurable.class);
|
||||
protected final InspectionProfileManager myProfileManager;
|
||||
protected final InspectionProjectProfileManager myProjectProfileManager;
|
||||
private final CardLayout myLayout = new CardLayout();
|
||||
@@ -111,7 +111,12 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
myProfiles = new ProfilesConfigurableComboBox(new ListCellRendererWrapper<Profile>() {
|
||||
@Override
|
||||
public void customize(final JList list, final Profile value, final int index, final boolean selected, final boolean hasFocus) {
|
||||
final SingleInspectionProfilePanel singleInspectionProfilePanel = myPanels.get(value);
|
||||
final SingleInspectionProfilePanel singleInspectionProfilePanel = getProfilePanel(value);
|
||||
LOG.assertTrue(singleInspectionProfilePanel != null,
|
||||
String.format("No panel for profile (name = %s, manager class = %s, is modified = %s) found",
|
||||
value.getName(),
|
||||
value.getProfileManager().getClass(),
|
||||
((InspectionProfileImpl) value).isChanged()));
|
||||
final boolean isShared = singleInspectionProfilePanel.isProfileShared();
|
||||
setIcon(isShared ? AllIcons.General.ProjectSettings : AllIcons.General.Settings);
|
||||
setText(singleInspectionProfilePanel.getCurrentProfileName());
|
||||
|
||||
@@ -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.
|
||||
@@ -45,6 +45,7 @@ public abstract class AbstractCollectionComboBoxModel<T> extends AbstractListMod
|
||||
public void setSelectedItem(@Nullable Object anItem) {
|
||||
//noinspection unchecked
|
||||
mySelection = (T)anItem;
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2332,8 +2332,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
UIUtil.drawLine(g, end.x, y1, end.x + charWidth - 1, y1);
|
||||
}
|
||||
else if (attributes.getEffectType() == EffectType.BOLD_LINE_UNDERSCORE) {
|
||||
UIUtil.drawLine(g, end.x, y - 1, end.x + charWidth - 1, y - 1);
|
||||
UIUtil.drawLine(g, end.x, y, end.x + charWidth - 1, y);
|
||||
drawBoldLineUnderScore(g, end.x, y - 1, charWidth - 1);
|
||||
}
|
||||
else if (attributes.getEffectType() != EffectType.BOXED) {
|
||||
UIUtil.drawLine(g, end.x, y, end.x + charWidth - 1, y);
|
||||
@@ -2342,6 +2341,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawBoldLineUnderScore(Graphics g, int x, int y, int width) {
|
||||
int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
|
||||
g.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWidthInRange(int startOffset, int endOffset) {
|
||||
if (myUseNewRendering) return myView.getMaxWidthInRange(startOffset, endOffset);
|
||||
@@ -3423,8 +3427,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
|
||||
g.setColor(effectColor);
|
||||
UIUtil.drawLine(g, xStart, y, xEnd, y);
|
||||
UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
|
||||
drawBoldLineUnderScore(g, xStart, y, xEnd-xStart);
|
||||
g.setColor(savedColor);
|
||||
}
|
||||
else if (effectType == EffectType.STRIKEOUT) {
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
"*.hprof;*.pyc;*.pyo;*.rbc;*~;.DS_Store;.bundle;.git;.hg;.svn;CVS;RCS;SCCS;__pycache__;.tox;_svn;rcs;vssver.scc;vssver2.scc;";
|
||||
|
||||
private static boolean RE_DETECT_ASYNC = !ApplicationManager.getApplication().isUnitTestMode();
|
||||
private final Collection<FileType> myDefaultTypes = new THashSet<FileType>();
|
||||
private final Set<FileType> myDefaultTypes = new THashSet<FileType>();
|
||||
private final List<FileTypeIdentifiableByVirtualFile> mySpecialFileTypes = new ArrayList<FileTypeIdentifiableByVirtualFile>();
|
||||
|
||||
private FileTypeAssocTable<FileType> myPatternsTable = new FileTypeAssocTable<FileType>();
|
||||
@@ -1007,7 +1007,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
|
||||
List<FileType> notExternalizableFileTypes = new ArrayList<FileType>();
|
||||
for (FileType type : mySchemesManager.getAllSchemes()) {
|
||||
if (!(type instanceof AbstractFileType)) {
|
||||
if (!(type instanceof AbstractFileType) || myDefaultTypes.contains(type)) {
|
||||
notExternalizableFileTypes.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,9 @@ public class KeyStrokeAdapter implements KeyListener {
|
||||
* @see KeyStroke#getKeyStrokeForEvent(KeyEvent)
|
||||
*/
|
||||
public static KeyStroke getDefaultKeyStroke(KeyEvent event) {
|
||||
if (event == null || event.isConsumed()) return null;
|
||||
// On Windows and Mac it is preferable to use normal key code here
|
||||
boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac;
|
||||
boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac && event.getModifiers() == 0;
|
||||
KeyStroke stroke = getKeyStroke(event, extendedKeyCodeFirst);
|
||||
return stroke != null ? stroke : getKeyStroke(event, !extendedKeyCodeFirst);
|
||||
}
|
||||
|
||||
@@ -46,10 +46,7 @@ import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.PlainDocument;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ListIterator;
|
||||
@@ -72,6 +69,22 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
|
||||
public SpeedSearchBase(Comp component) {
|
||||
myComponent = component;
|
||||
|
||||
myComponent.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent event) {
|
||||
manageSearchPopup(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent event) {
|
||||
moveSearchPopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent event) {
|
||||
moveSearchPopup();
|
||||
}
|
||||
});
|
||||
myComponent.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
@@ -568,7 +581,11 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
|
||||
return;
|
||||
}
|
||||
myPopupLayeredPane.add(mySearchPopup, JLayeredPane.POPUP_LAYER);
|
||||
if (myPopupLayeredPane == null) return; // See # 27482. Somewho it does happen...
|
||||
moveSearchPopup();
|
||||
}
|
||||
|
||||
private void moveSearchPopup() {
|
||||
if (myComponent == null || mySearchPopup == null || myPopupLayeredPane == null) return;
|
||||
Point lPaneP = myPopupLayeredPane.getLocationOnScreen();
|
||||
Point componentP = getComponentLocationOnScreen();
|
||||
Rectangle r = getComponentVisibleRect();
|
||||
|
||||
@@ -306,9 +306,11 @@
|
||||
</option>
|
||||
<option name="WARNING_ATTRIBUTES">
|
||||
<value>
|
||||
<option name="EFFECT_COLOR" value="e68110" />
|
||||
<option name="FOREGROUND"/>
|
||||
<option name="BACKGROUND" value="f6ebbc"/>
|
||||
<option name="EFFECT_COLOR"/>
|
||||
<option name="EFFECT_TYPE" value="1"/>
|
||||
<option name="ERROR_STRIPE_COLOR" value="ebc700" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GENERIC_SERVER_ERROR_OR_WARNING">
|
||||
@@ -2579,9 +2581,9 @@
|
||||
</option>
|
||||
<option name="WARNING_ATTRIBUTES">
|
||||
<value>
|
||||
<option name="EFFECT_COLOR" value="af8000" />
|
||||
<option name="ERROR_STRIPE_COLOR" value="be9117" />
|
||||
<option name="BACKGROUND" value="52503a" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" value="be9117" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES">
|
||||
|
||||
+89
-18
@@ -17,15 +17,18 @@ package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.util.ExecUtil;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
@@ -36,6 +39,23 @@ import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class GeneralCommandLineTest {
|
||||
|
||||
private static final String[] ARGUMENTS = {
|
||||
"with space",
|
||||
"\"quoted\"",
|
||||
"\"quoted with spaces\"",
|
||||
"",
|
||||
" ",
|
||||
"param 1",
|
||||
"\"",
|
||||
"quote\"inside",
|
||||
"space \"and \"quotes\" inside",
|
||||
"\"space \"and \"quotes\" inside\"",
|
||||
"param2",
|
||||
"trailing slash\\",
|
||||
// "two trailing slashes\\\\" /* doesn't work on Windows*/
|
||||
};
|
||||
|
||||
@Test
|
||||
public void printCommandLine() {
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||
@@ -89,8 +109,9 @@ public class GeneralCommandLineTest {
|
||||
File dir = FileUtil.createTempDirectory("path with spaces 'and quotes' и юникодом ", ".tmp");
|
||||
try {
|
||||
GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, dir);
|
||||
commandLine.addParameter("test");
|
||||
String output = execAndGetOutput(commandLine, null);
|
||||
assertEquals("=====\n=====\n", StringUtil.convertLineSeparators(output));
|
||||
assertEquals("test\n", StringUtil.convertLineSeparators(output));
|
||||
}
|
||||
finally {
|
||||
FileUtil.delete(dir);
|
||||
@@ -98,20 +119,62 @@ public class GeneralCommandLineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void argumentsPassing() throws Exception {
|
||||
String[] parameters = {
|
||||
"with space", "\"quoted\"", "\"quoted with spaces\"", "", " ", "param 1", "\"", "param2", "trailing slash\\"
|
||||
};
|
||||
|
||||
public void testPassingArgumentsToJavaApp() throws Exception {
|
||||
GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null);
|
||||
commandLine.addParameters(parameters);
|
||||
String[] args = ArrayUtil.mergeArrays(ARGUMENTS, "&<>()@^|", "\"&<>()@^|\"");
|
||||
commandLine.addParameters(args);
|
||||
String output = execAndGetOutput(commandLine, null);
|
||||
assertEquals("=====\n" + StringUtil.join(parameters, new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String s) {
|
||||
return ParamPassingTest.format(s);
|
||||
}
|
||||
}, "\n") + "\n=====\n", StringUtil.convertLineSeparators(output));
|
||||
assertParamPassingTestOutput(output, args);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPassingArgumentsToJavaAppThroughWinShell() throws Exception {
|
||||
assumeTrue(SystemInfo.isWindows);
|
||||
// passing "^" argument doesn't work for cmd.exe
|
||||
String[] args = ARGUMENTS;
|
||||
GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null);
|
||||
String oldExePath = commandLine.getExePath();
|
||||
commandLine.setExePath("cmd.exe");
|
||||
// the test will fails if "call" is omitted
|
||||
commandLine.getParametersList().prependAll("/D", "/C", "call", oldExePath);
|
||||
commandLine.addParameters(args);
|
||||
String output = execAndGetOutput(commandLine, null);
|
||||
assertParamPassingTestOutput(output, args);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPassingArgumentsToJavaAppThroughCmdScriptAndWinShell() throws Exception {
|
||||
assumeTrue(SystemInfo.isWindows);
|
||||
// passing "^" argument doesn't work for cmd.exe
|
||||
String[] args = ARGUMENTS;
|
||||
File cmdScript = createCmdFileLaunchingJavaApp();
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||
commandLine.setExePath("cmd.exe");
|
||||
// the test will fails if "call" is omitted
|
||||
commandLine.addParameters("/D", "/C", "call", cmdScript.getAbsolutePath());
|
||||
commandLine.addParameters(args);
|
||||
String output = execAndGetOutput(commandLine, null);
|
||||
assertParamPassingTestOutput(output, args);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private File createCmdFileLaunchingJavaApp() throws Exception {
|
||||
File cmdScript = FileUtil.createTempFile(new File(PathManager.getTempPath(), "My Program Files" /* path with spaces */),
|
||||
"my-script", ".cmd", true, true);
|
||||
GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null);
|
||||
FileUtil.writeToFile(cmdScript, "@" + commandLine.getCommandLineString() + " %*");
|
||||
if (!cmdScript.setExecutable(true, true)) {
|
||||
throw new ExecutionException("Failed to make temp file executable: " + cmdScript);
|
||||
}
|
||||
return cmdScript;
|
||||
}
|
||||
|
||||
private static void assertParamPassingTestOutput(@NotNull String actualOutput, @NotNull String... expectedOutputParameters) {
|
||||
String content = StringUtil.join(expectedOutputParameters, "\n");
|
||||
if (expectedOutputParameters.length > 0) {
|
||||
content += "\n";
|
||||
}
|
||||
assertEquals(content, StringUtil.convertLineSeparators(actualOutput));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -250,11 +313,19 @@ public class GeneralCommandLineTest {
|
||||
|
||||
private static String execAndGetOutput(GeneralCommandLine commandLine, @Nullable String encoding) throws Exception {
|
||||
Process process = commandLine.createProcess();
|
||||
byte[] bytes = FileUtil.loadBytes(process.getInputStream());
|
||||
String output = encoding != null ? new String(bytes, encoding) : new String(bytes);
|
||||
String stdOut = loadTextFromStream(process.getInputStream(), encoding);
|
||||
String stdErr = loadTextFromStream(process.getErrorStream(), encoding);
|
||||
int result = process.waitFor();
|
||||
assertEquals("Command:\n" + commandLine.getCommandLineString() + "\nOutput:\n" + output, 0, result);
|
||||
return output;
|
||||
assertEquals("Command:\n" + commandLine.getCommandLineString()
|
||||
+ "\nStandard output:\n" + stdOut
|
||||
+ "\nStandard error:\n" + stdErr,
|
||||
0, result);
|
||||
return stdOut;
|
||||
}
|
||||
|
||||
private static String loadTextFromStream(@NotNull InputStream stream, @Nullable String encoding) throws IOException {
|
||||
byte[] bytes = FileUtil.loadBytes(stream);
|
||||
return encoding != null ? new String(bytes, encoding) : new String(bytes);
|
||||
}
|
||||
|
||||
private GeneralCommandLine makeJavaCommand(Class<?> testClass, @Nullable File copyTo) throws IOException, URISyntaxException {
|
||||
|
||||
@@ -17,14 +17,8 @@ package com.intellij.execution;
|
||||
|
||||
public class ParamPassingTest {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=====");
|
||||
for (String arg : args) {
|
||||
System.out.println(format(arg));
|
||||
System.out.println(arg);
|
||||
}
|
||||
System.out.println("=====");
|
||||
}
|
||||
|
||||
public static String format(String arg) {
|
||||
return String.valueOf(arg.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -351,7 +351,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
}
|
||||
|
||||
private static void log(String message) {
|
||||
//System.out.println(message);
|
||||
System.out.println(message);
|
||||
}
|
||||
|
||||
private void ensureRedetected(VirtualFile vFile, Set<VirtualFile> detectorCalled) {
|
||||
@@ -510,4 +510,18 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
fail(JDOMUtil.writeElement(map));
|
||||
}
|
||||
}
|
||||
|
||||
public void testDefaultFileType() throws Exception {
|
||||
FileType idl = myFileTypeManager.findFileTypeByName("IDL");
|
||||
myFileTypeManager.associatePattern(idl, "*.xxx");
|
||||
Element element = myFileTypeManager.getState();
|
||||
log(JDOMUtil.writeElement(element));
|
||||
myFileTypeManager.removeAssociatedExtension(idl, "xxx");
|
||||
myFileTypeManager.clearForTests();
|
||||
myFileTypeManager.initStandardFileTypes();
|
||||
myFileTypeManager.loadState(element);
|
||||
myFileTypeManager.initComponent();
|
||||
FileType extensions = myFileTypeManager.getFileTypeByExtension("xxx");
|
||||
assertEquals("IDL", extensions.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
|
||||
// tree construction events
|
||||
|
||||
public void onRootPresentationAdded(String rootName, String comment) {}
|
||||
public void onRootPresentationAdded(String rootName, String comment, String rootLocation) {}
|
||||
|
||||
public void onSuiteTreeNodeAdded(String testName, String locationHint) { }
|
||||
|
||||
|
||||
+5
-1
@@ -115,12 +115,16 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRootPresentationAdded(final String rootName, final String comment) {
|
||||
public void onRootPresentationAdded(final String rootName, final String comment, final String rootLocation) {
|
||||
addToInvokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTestsRootNode.setPresentation(rootName);
|
||||
myTestsRootNode.setComment(comment);
|
||||
myTestsRootNode.setRootLocationUrl(rootLocation);
|
||||
if (myLocator != null) {
|
||||
myTestsRootNode.setLocator(myLocator);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-3
@@ -215,10 +215,10 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
|
||||
|
||||
private void fireRootPresentationAdded(String rootName, @Nullable String comment) {
|
||||
private void fireRootPresentationAdded(String rootName, @Nullable String comment, String rootLocation) {
|
||||
final GeneralTestEventsProcessor processor = myProcessor;
|
||||
if (processor != null) {
|
||||
processor.onRootPresentationAdded(rootName, comment);
|
||||
processor.onRootPresentationAdded(rootName, comment, rootLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
|
||||
}
|
||||
else if (ROOT_PRESENTATION.equals(name)) {
|
||||
final Map<String, String> attributes = msg.getAttributes();
|
||||
fireRootPresentationAdded(attributes.get("name"), attributes.get("comment"));
|
||||
fireRootPresentationAdded(attributes.get("name"), attributes.get("comment"), attributes.get("location"));
|
||||
}
|
||||
else {
|
||||
GeneralToSMTRunnerEventsConvertor.logProblem(LOG, "Unexpected service message:" + name, myTestFrameworkName);
|
||||
|
||||
+20
-3
@@ -267,10 +267,15 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
@Nullable
|
||||
public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
//determines location of test proxy
|
||||
if (myLocationUrl != null && myLocator != null) {
|
||||
String protocolId = VirtualFileManager.extractProtocol(myLocationUrl);
|
||||
final String locationUrl = myLocationUrl;
|
||||
return getLocation(project, searchScope, locationUrl);
|
||||
}
|
||||
|
||||
protected Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope, String locationUrl) {
|
||||
if (locationUrl != null && myLocator != null) {
|
||||
String protocolId = VirtualFileManager.extractProtocol(locationUrl);
|
||||
if (protocolId != null) {
|
||||
String path = VirtualFileManager.extractPath(myLocationUrl);
|
||||
String path = VirtualFileManager.extractPath(locationUrl);
|
||||
if (!DumbService.isDumb(project) || DumbService.isDumbAware(myLocator)) {
|
||||
List<Location> locations = myLocator.getLocation(protocolId, path, project, searchScope);
|
||||
if (!locations.isEmpty()) {
|
||||
@@ -742,6 +747,7 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
|
||||
private String myPresentation;
|
||||
private String myComment;
|
||||
private String myRootLocationUrl;
|
||||
|
||||
public SMRootTestProxy() {
|
||||
super("[root]", true, null);
|
||||
@@ -771,6 +777,17 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
return myComment;
|
||||
}
|
||||
|
||||
public void setRootLocationUrl(String locationUrl) {
|
||||
myRootLocationUrl = locationUrl;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
return myRootLocationUrl != null ? super.getLocation(project, searchScope, myRootLocationUrl)
|
||||
: super.getLocation(project, searchScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractState determineSuiteStateOnFinished() {
|
||||
if (isLeaf() && !isTestsReporterAttached()) {
|
||||
|
||||
+2
-19
@@ -47,9 +47,6 @@ import static com.intellij.execution.testframework.sm.runner.ui.SMPoolOfTestIcon
|
||||
*/
|
||||
public class TestsPresentationUtil {
|
||||
@NonNls private static final String DOUBLE_SPACE = " ";
|
||||
@NonNls private static final String SECONDS_SUFFIX = " " + SMTestsRunnerBundle.message("sm.test.runner.ui.tests.tree.presentation.labels.seconds");
|
||||
@NonNls private static final String MILLISECONDS_SUFFIX = " " + SMTestsRunnerBundle.message("sm.test.runner.ui.tests.tree.presentation.labels.milliseconds");
|
||||
@NonNls private static final String WORLD_CREATION_TIME = "0" + SECONDS_SUFFIX;
|
||||
@NonNls private static final String DURATION_UNKNOWN = SMTestsRunnerBundle.message(
|
||||
"sm.test.runner.ui.tabs.statistics.columns.duration.unknown");
|
||||
@NonNls private static final String DURATION_NO_TESTS = SMTestsRunnerBundle.message(
|
||||
@@ -131,7 +128,7 @@ public class TestsPresentationUtil {
|
||||
if (endTime != 0) {
|
||||
final long time = endTime - startTime;
|
||||
sb.append(DOUBLE_SPACE);
|
||||
sb.append('(').append(convertToSecondsOrMs(time)).append(')');
|
||||
sb.append('(').append(StringUtil.formatDuration(time)).append(')');
|
||||
}
|
||||
sb.append(DOUBLE_SPACE);
|
||||
|
||||
@@ -413,21 +410,7 @@ public class TestsPresentationUtil {
|
||||
? DURATION_NO_TESTS
|
||||
: DURATION_UNKNOWN;
|
||||
} else {
|
||||
return convertToSecondsOrMs(duration.longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duration In milliseconds
|
||||
* @return Value in seconds or millisecond depending on its value
|
||||
*/
|
||||
private static String convertToSecondsOrMs(@NotNull final Long duration) {
|
||||
if (duration == 0) {
|
||||
return WORLD_CREATION_TIME;
|
||||
} else if (duration < 100) {
|
||||
return String.valueOf(duration) + MILLISECONDS_SUFFIX;
|
||||
} else {
|
||||
return String.valueOf(duration.floatValue() / 1000) + SECONDS_SUFFIX;
|
||||
return StringUtil.formatDuration(duration.longValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -29,6 +29,18 @@ public class MockPrinter implements Printer {
|
||||
protected final StringBuilder myStdErr = new StringBuilder();
|
||||
protected final StringBuilder myStdSys = new StringBuilder();
|
||||
|
||||
/**
|
||||
* Creates printer and prints printable on it.
|
||||
* @param printable printable to print on this printer
|
||||
* @return printer filled with printable output
|
||||
*/
|
||||
@NotNull
|
||||
public static MockPrinter fillPrinter(@NotNull Printable printable) {
|
||||
MockPrinter printer = new MockPrinter();
|
||||
printable.printOn(printer);
|
||||
return printer;
|
||||
}
|
||||
|
||||
public MockPrinter() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
|
||||
assertEquals("Running: 10 of 1 ",
|
||||
TestsPresentationUtil.getProgressStatus_Text(0, 0, 1, 10, 0, null, true));
|
||||
//here number format is platform-dependent
|
||||
assertEquals("Done: 10 of 1 (0 s) ",
|
||||
assertEquals("Done: 10 of 1 (0ms) ",
|
||||
TestsPresentationUtil.getProgressStatus_Text(5, 5, 1, 10, 0, null, false));
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
|
||||
assertEquals("Running: 10 of <...> Failed: 1 ",
|
||||
TestsPresentationUtil.getProgressStatus_Text(0, 0, 0, 10, 1, null, false));
|
||||
//here number format is platform-dependent
|
||||
assertEquals("Done: 10 of <...> Failed: 1 (5 ms) ",
|
||||
assertEquals("Done: 10 of <...> Failed: 1 (5ms) ",
|
||||
TestsPresentationUtil.getProgressStatus_Text(0, 5, 0, 10, 1, null, false));
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -41,7 +41,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("10s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_TestPassed() {
|
||||
@@ -50,7 +50,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("10s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_TestError() {
|
||||
@@ -59,7 +59,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("10s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_TestTerminated() {
|
||||
@@ -68,7 +68,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<TERMINATED>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(10000);
|
||||
assertEquals("TERMINATED: " + String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("TERMINATED: 10s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_TestIgnored() {
|
||||
@@ -78,7 +78,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("10s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_Zero() {
|
||||
@@ -87,7 +87,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(0);
|
||||
assertEquals("0 s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("0ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_1() {
|
||||
@@ -96,7 +96,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(1);
|
||||
assertEquals("1 ms", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("1ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_99() {
|
||||
@@ -105,7 +105,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(99);
|
||||
assertEquals("99 ms", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("99ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_100() {
|
||||
@@ -114,7 +114,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(100);
|
||||
assertEquals(String.valueOf((float)0.1) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("100ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_999() {
|
||||
@@ -123,7 +123,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(999);
|
||||
assertEquals(String.valueOf((float)0.999) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("999ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_1000() {
|
||||
@@ -132,7 +132,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(1000);
|
||||
assertEquals(String.valueOf((float)1) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("1s", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_Duration_1001() {
|
||||
@@ -141,7 +141,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(mySimpleTest));
|
||||
|
||||
mySimpleTest.setDuration(1001);
|
||||
assertEquals(String.valueOf((float)1.001) + " s", myColumn.valueOf(mySimpleTest));
|
||||
assertEquals("1s 1ms", myColumn.valueOf(mySimpleTest));
|
||||
}
|
||||
|
||||
public void testValueOf_SuiteEmpty() {
|
||||
@@ -176,7 +176,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(suite));
|
||||
|
||||
test.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite));
|
||||
assertEquals("10s", myColumn.valueOf(suite));
|
||||
}
|
||||
|
||||
public void testValueOf_SuiteError() {
|
||||
@@ -190,7 +190,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(suite));
|
||||
|
||||
test.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite));
|
||||
assertEquals("10s", myColumn.valueOf(suite));
|
||||
}
|
||||
|
||||
public void testValueOf_SuitePassed() {
|
||||
@@ -204,7 +204,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<UNKNOWN>", myColumn.valueOf(suite));
|
||||
|
||||
test.setDuration(10000);
|
||||
assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite));
|
||||
assertEquals("10s", myColumn.valueOf(suite));
|
||||
}
|
||||
|
||||
public void testValueOf_SuiteTerminated() {
|
||||
@@ -217,7 +217,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<TERMINATED>", myColumn.valueOf(suite));
|
||||
|
||||
test.setDuration(10000);
|
||||
assertEquals("TERMINATED: " + String.valueOf((float)10) + " s", myColumn.valueOf(suite));
|
||||
assertEquals("TERMINATED: 10s", myColumn.valueOf(suite));
|
||||
}
|
||||
|
||||
public void testValueOf_SuiteRunning() {
|
||||
@@ -230,7 +230,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
assertEquals("<RUNNING>", myColumn.valueOf(suite));
|
||||
|
||||
test.setDuration(10000);
|
||||
assertEquals("RUNNING: " + String.valueOf((float)10) + " s", myColumn.valueOf(suite));
|
||||
assertEquals("RUNNING: 10s", myColumn.valueOf(suite));
|
||||
}
|
||||
|
||||
public void testTotal_Test() {
|
||||
|
||||
@@ -539,6 +539,9 @@ editor.xcode.like.scrollbar.description=Enables auto-hideable Xcode-like editor
|
||||
editor.config.stop.at.project.root=true
|
||||
editor.config.stop.at.project.root.description=Stops searching for .editorconfig at project root (requires project reopening)
|
||||
|
||||
editor.bold.underline.height=2
|
||||
editor.bold.underline.height.description=Underline height for EffectType.BOLD_LINE_UNDERSCORE
|
||||
|
||||
JDK8042508.bug.fixed=false
|
||||
JDK8042508.bug.fixed.description=Disable check for type variable until javac bug is fixed
|
||||
|
||||
|
||||
@@ -188,7 +188,9 @@ public class Foundation {
|
||||
public static String getEncodingName(long nsStringEncoding) {
|
||||
long cfEncoding = myFoundationLibrary.CFStringConvertNSStringEncodingToEncoding(nsStringEncoding);
|
||||
ID pointer = myFoundationLibrary.CFStringConvertEncodingToIANACharSetName(cfEncoding);
|
||||
return toStringViaUTF8(pointer);
|
||||
String name = toStringViaUTF8(pointer);
|
||||
if ("macintosh".equals(name)) name = "MacRoman"; // JDK8 does not recognize IANA's "macintosh" alias
|
||||
return name;
|
||||
}
|
||||
|
||||
public static long getEncodingCode(@Nullable String encodingName) {
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
package com.intellij.util.lang;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.misc.Resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -53,13 +52,8 @@ class JarLoader extends Loader {
|
||||
}
|
||||
}
|
||||
|
||||
private File getFileUrl() throws IOException {
|
||||
try {
|
||||
return new File(myURL.toURI());
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
private String getFileUrl() throws IOException {
|
||||
return FileUtil.unquote(myURL.getFile());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+56
-6
@@ -16,12 +16,11 @@
|
||||
package com.siyeh.ig.psiutils;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
|
||||
public class SynchronizationUtil {
|
||||
|
||||
private SynchronizationUtil() {
|
||||
}
|
||||
private SynchronizationUtil() {}
|
||||
|
||||
public static boolean isInSynchronizedContext(PsiElement element) {
|
||||
final PsiElement context =
|
||||
@@ -29,10 +28,61 @@ public class SynchronizationUtil {
|
||||
if (context instanceof PsiSynchronizedStatement) {
|
||||
return true;
|
||||
}
|
||||
if (!(context instanceof PsiMethod)) {
|
||||
if (context instanceof PsiMethod) {
|
||||
final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)context;
|
||||
if (modifierListOwner.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (context instanceof PsiMethod || context instanceof PsiLambdaExpression) {
|
||||
final HoldsLockAssertionVisitor visitor = new HoldsLockAssertionVisitor();
|
||||
context.accept(visitor);
|
||||
final PsiAssertStatement assertStatement = visitor.getAssertStatement();
|
||||
return assertStatement != null && assertStatement.getTextOffset() + assertStatement.getTextLength() < element.getTextOffset();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCallToHoldsLock(PsiExpression expression) {
|
||||
expression = ParenthesesUtils.stripParentheses(expression);
|
||||
if (!(expression instanceof PsiMethodCallExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)context;
|
||||
return modifierListOwner.hasModifierProperty(PsiModifier.SYNCHRONIZED);
|
||||
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
|
||||
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
|
||||
final String name = methodExpression.getReferenceName();
|
||||
if (!"holdsLock".equals(name)) {
|
||||
return false;
|
||||
}
|
||||
final PsiMethod method = methodCallExpression.resolveMethod();
|
||||
if (method == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiClass aClass = method.getContainingClass();
|
||||
return com.intellij.psi.util.InheritanceUtil.isInheritor(aClass, "java.lang.Thread");
|
||||
}
|
||||
|
||||
private static class HoldsLockAssertionVisitor extends JavaRecursiveElementVisitor {
|
||||
private PsiAssertStatement myAssertStatement = null;
|
||||
|
||||
@Override
|
||||
public void visitAssertStatement(PsiAssertStatement statement) {
|
||||
if (myAssertStatement != null) return;
|
||||
super.visitAssertStatement(statement);
|
||||
final PsiExpression condition = statement.getAssertCondition();
|
||||
if (isCallToHoldsLock(condition)) {
|
||||
myAssertStatement = statement;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (myAssertStatement != null) return;
|
||||
super.visitElement(element);
|
||||
}
|
||||
|
||||
public PsiAssertStatement getAssertStatement() {
|
||||
return myAssertStatement;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -21,6 +21,7 @@ import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.siyeh.ig.psiutils.SynchronizationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -61,6 +62,14 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
|
||||
m_inSynchronizedContext = wasInSync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLambdaExpression(PsiLambdaExpression expression) {
|
||||
final boolean wasInSync = m_inSynchronizedContext;
|
||||
m_inSynchronizedContext = false;
|
||||
super.visitLambdaExpression(expression);
|
||||
m_inSynchronizedContext = wasInSync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(@NotNull PsiReferenceExpression ref) {
|
||||
super.visitReferenceExpression(ref);
|
||||
@@ -128,6 +137,15 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
|
||||
m_inSynchronizedContext = wasInSync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAssertStatement(PsiAssertStatement statement) {
|
||||
final PsiExpression condition = statement.getAssertCondition();
|
||||
if (SynchronizationUtil.isCallToHoldsLock(condition)) {
|
||||
m_inSynchronizedContext = true;
|
||||
}
|
||||
super.visitAssertStatement(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethod(@NotNull PsiMethod method) {
|
||||
if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
|
||||
+7
-3
@@ -3,12 +3,16 @@ package com.siyeh.igtest.threading.call_to_native_method_while_locked;
|
||||
public class CallToNativeMethodWhileLocked {
|
||||
|
||||
synchronized void a() {
|
||||
Double.<warning descr="Call to native method 'doubleToLongBits()' in a synchronized context">doubleToLongBits</warning>(9.7);
|
||||
Double.<warning descr="Call to native method 'doubleToRawLongBits()' in a synchronized context">doubleToRawLongBits</warning>(9.7);
|
||||
Runnable r = () -> {
|
||||
Double.doubleToLongBits(123.4);
|
||||
Double.doubleToRawLongBits(123.4);
|
||||
};
|
||||
new Object() {
|
||||
long l = Double.doubleToLongBits(42.0);
|
||||
long l = Double.doubleToRawLongBits(42.0);
|
||||
};
|
||||
Runnable s = () -> {
|
||||
assert Thread.holdsLock(this);
|
||||
Double.<warning descr="Call to native method 'doubleToRawLongBits()' in a synchronized context">doubleToRawLongBits</warning>(40.0);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -4,12 +4,16 @@ public class FieldAccessedSynchronizedAndUnsynchronized
|
||||
{
|
||||
private final Object m_lock = new Object();
|
||||
private Object <warning descr="Field 'm_contents' is accessed in both synchronized and unsynchronized contexts">m_contents</warning> = new Object();
|
||||
private Object <warning descr="Field 'a' is accessed in both synchronized and unsynchronized contexts">a</warning>;
|
||||
private Object b;
|
||||
|
||||
public void foo()
|
||||
{
|
||||
synchronized(m_lock)
|
||||
{
|
||||
m_contents = new Object();
|
||||
a = new Object();
|
||||
b = new Object();
|
||||
}
|
||||
getContents();
|
||||
}
|
||||
@@ -24,6 +28,17 @@ public class FieldAccessedSynchronizedAndUnsynchronized
|
||||
getContents();
|
||||
}
|
||||
|
||||
public synchronized void g() {
|
||||
Runnable r = () -> {
|
||||
System.out.println(a);
|
||||
};
|
||||
}
|
||||
|
||||
public void h() {
|
||||
assert Thread.holdsLock(m_lock);
|
||||
System.out.println(b);
|
||||
}
|
||||
|
||||
}
|
||||
class Test {
|
||||
private Object <warning descr="Field 'object' is accessed in both synchronized and unsynchronized contexts">object</warning>;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.execution.junit2.ui;
|
||||
|
||||
import com.intellij.execution.junit2.states.CumulativeStatistics;
|
||||
import com.intellij.execution.junit2.states.Statistics;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
class ActualStatistics implements TestStatistics {
|
||||
private final CumulativeStatistics myStatistics = new CumulativeStatistics();
|
||||
@@ -32,7 +33,7 @@ class ActualStatistics implements TestStatistics {
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return myPrefix + Formatters.printTime(myStatistics.getTime());
|
||||
return myPrefix + StringUtil.formatDuration(myStatistics.getTime());
|
||||
}
|
||||
|
||||
public String getMemoryUsageDelta() {
|
||||
|
||||
@@ -32,32 +32,6 @@ public class Formatters {
|
||||
return info.getName() + sensibleCommentFor(test);
|
||||
}
|
||||
|
||||
public static String printTime(final long milliseconds) {
|
||||
if (milliseconds == 0) {
|
||||
return ExecutionBundle.message("junit.runing.info.time.sec.message", "0.0");
|
||||
}
|
||||
long seconds = milliseconds / 1000;
|
||||
if (seconds == 0) {
|
||||
return ExecutionBundle.message("junit.runing.info.time.sec.message", NumberFormat.getInstance().format((double)milliseconds/1000.0));
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
if (seconds >= 3600) {
|
||||
sb.append(seconds / 3600).append("h ");
|
||||
seconds %= 3600;
|
||||
}
|
||||
|
||||
if (seconds >= 60) {
|
||||
sb.append(seconds / 60).append("m ");
|
||||
seconds %= 60;
|
||||
}
|
||||
|
||||
if (seconds > 0 || sb.length() > 0) {
|
||||
sb.append(seconds).append("s");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String printMemory(final long memory) {
|
||||
final String string = printMemoryUnsigned(memory);
|
||||
return memory > 0 ? "+" + string : string;
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package com.intellij.execution.junit2.ui.model;
|
||||
|
||||
import com.intellij.execution.junit2.ui.Formatters;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
public class CompletionEvent extends StateEvent {
|
||||
private final boolean myNormalExit;
|
||||
|
||||
public CompletionEvent(final boolean normalExit, final long time) {
|
||||
super(normalExit ? TerminatedType.DONE: TerminatedType.TERNINATED,
|
||||
time >= 0 ? "in " + Formatters.printTime(time) : "");
|
||||
time >= 0 ? "in " + StringUtil.formatDuration(time) : "");
|
||||
myNormalExit = normalExit;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -64,7 +64,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
|
||||
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'root']\n" +
|
||||
"##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
|
||||
"##teamcity[testSuiteFinished name='root']\n" +
|
||||
"##teamcity[testSuiteStarted name ='TestA']\n" +
|
||||
"##teamcity[testSuiteStarted name ='|[0|]']\n" +
|
||||
@@ -108,7 +108,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
"##teamcity[suiteTreeEnded name='|[1|]']\n",
|
||||
//start
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'TestA' comment = 'a']\n" +
|
||||
"##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" +
|
||||
"##teamcity[testSuiteStarted name ='|[0|]']\n" +
|
||||
"##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" +
|
||||
"\n" +
|
||||
@@ -153,7 +153,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
|
||||
//started
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'root']\n" +
|
||||
"##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
|
||||
"##teamcity[testSuiteFinished name='root']\n" +
|
||||
"##teamcity[testSuiteStarted name ='ASuite1']\n" +
|
||||
"##teamcity[testSuiteStarted name ='ATest']\n" +
|
||||
@@ -232,7 +232,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
|
||||
//start
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'root']\n" +
|
||||
"##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
|
||||
"##teamcity[testSuiteFinished name='root']\n" +
|
||||
"##teamcity[testSuiteStarted name ='ATest']\n" +
|
||||
"##teamcity[testSuiteStarted name ='|[0|]']\n" +
|
||||
@@ -288,7 +288,7 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
|
||||
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'TestA']\n" +
|
||||
"##teamcity[rootName name = 'TestA' location = 'java:suite://TestA']\n" +
|
||||
"##teamcity[testStarted name='warning' locationHint='java:test://junit.framework.TestSuite$1.warning']\n" +
|
||||
"\n" +
|
||||
"##teamcity[testFinished name='warning']\n" +
|
||||
|
||||
@@ -72,7 +72,8 @@ public class SMTestSender extends RunListener {
|
||||
}
|
||||
|
||||
myPrintStream.println("##teamcity[rootName name = \'" + escapeName(name) +
|
||||
(comment != null ? ("\' comment = \'" + escapeName(comment)) : "") +
|
||||
(comment != null ? ("\' comment = \'" + escapeName(comment)) : "") + "\'" +
|
||||
" location = \'java:suite://" + escapeName(myCurrentClassName) +
|
||||
"\']");
|
||||
myCurrentClassName = getShortName(myCurrentClassName);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public class IDEARemoteTestNG extends TestNG {
|
||||
addListener((ISuiteListener) new IDEATestNGRemoteListener());
|
||||
addListener((ITestListener) new IDEATestNGRemoteListener());
|
||||
super.run();
|
||||
System.exit(0);
|
||||
}
|
||||
else {
|
||||
System.err.println("Nothing found to run");
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.testng.internal.IResultListener;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -20,59 +20,63 @@ import java.util.Map;
|
||||
public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener{
|
||||
|
||||
public static final String INVOCATION_NUMBER = "invocation number: ";
|
||||
private PrintStream myPrintStream = System.out;
|
||||
private String myCurrentClassName;
|
||||
private final PrintStream myPrintStream;
|
||||
private String myCurrentClassName = null;
|
||||
private String myMethodName;
|
||||
private int myInvocationCount = 0;
|
||||
private int myInvocationCount = 0;
|
||||
private final Map<ITestResult, Integer> myMap = Collections.synchronizedMap(new HashMap<ITestResult, Integer>());
|
||||
|
||||
public IDEATestNGRemoteListener() {}
|
||||
public IDEATestNGRemoteListener() {
|
||||
myPrintStream = System.out;
|
||||
}
|
||||
|
||||
public IDEATestNGRemoteListener(PrintStream printStream) {
|
||||
myPrintStream = printStream;
|
||||
}
|
||||
|
||||
public void onStart(ISuite suite) {
|
||||
public synchronized void onStart(final ISuite suite) {
|
||||
myPrintStream.println("##teamcity[enteredTheMatrix]");
|
||||
onSuiteStart(suite.getName(), false);
|
||||
}
|
||||
|
||||
public void onFinish(ISuite suite) {
|
||||
public synchronized void onFinish(ISuite suite) {
|
||||
onSuiteFinish(suite.getName());
|
||||
}
|
||||
|
||||
public void onConfigurationSuccess(ITestResult result) {
|
||||
public synchronized void onConfigurationSuccess(ITestResult result) {
|
||||
onConfigurationSuccess(getClassName(result), getTestMethodName(result));
|
||||
}
|
||||
|
||||
public void onConfigurationFailure(ITestResult result) {
|
||||
public synchronized void onConfigurationFailure(ITestResult result) {
|
||||
onConfigurationFailure(getClassName(result), getTestMethodName(result), result.getThrowable());
|
||||
}
|
||||
|
||||
public void onConfigurationSkip(ITestResult itr) {}
|
||||
public synchronized void onConfigurationSkip(ITestResult itr) {}
|
||||
|
||||
public void onTestStart(ITestResult result) {
|
||||
onTestStart(getClassName(result), getMethodName(result, false));
|
||||
public synchronized void onTestStart(ITestResult result) {
|
||||
onTestStart(getClassName(result), getMethodName(result, true));
|
||||
}
|
||||
|
||||
public void onTestSuccess(ITestResult result) {
|
||||
public synchronized void onTestSuccess(ITestResult result) {
|
||||
onTestFinished(getMethodName(result));
|
||||
}
|
||||
|
||||
public void onTestFailure(ITestResult result) {
|
||||
public synchronized void onTestFailure(ITestResult result) {
|
||||
onTestFailure(result.getThrowable(), getMethodName(result));
|
||||
}
|
||||
|
||||
public void onTestSkipped(ITestResult result) {
|
||||
onTestFinished(getMethodName(result));
|
||||
public synchronized void onTestSkipped(ITestResult result) {
|
||||
myPrintStream.println("\n##teamcity[testIgnored name=\'" + escapeName(getMethodName(result)) + "\']");
|
||||
}
|
||||
|
||||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {}
|
||||
public synchronized void onTestFailedButWithinSuccessPercentage(ITestResult result) {}
|
||||
|
||||
public void onStart(ITestContext context) {}
|
||||
public synchronized void onStart(ITestContext context) {}
|
||||
|
||||
public void onFinish(ITestContext context) {
|
||||
if (myCurrentClassName != null) {
|
||||
onSuiteFinish(myCurrentClassName);
|
||||
public synchronized void onFinish(ITestContext context) {
|
||||
final String currentClassName = myCurrentClassName;
|
||||
if (currentClassName != null) {
|
||||
onSuiteFinish(currentClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +166,7 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
}
|
||||
|
||||
private String getMethodName(ITestResult result) {
|
||||
return getMethodName(result, true);
|
||||
return getMethodName(result, false);
|
||||
}
|
||||
|
||||
private String getMethodName(ITestResult result, boolean changeCount) {
|
||||
@@ -173,9 +177,13 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
myMethodName = methodName;
|
||||
}
|
||||
if (parameters.length > 0) {
|
||||
final List<Integer> invocationNumbers = result.getMethod().getInvocationNumbers();
|
||||
methodName += "[" + parameters[0].toString() + " (" + INVOCATION_NUMBER +
|
||||
(invocationNumbers.isEmpty() ? myInvocationCount : invocationNumbers.get(myInvocationCount)) + ")" + "]";
|
||||
Integer invocationCount = myMap.get(result);
|
||||
if (invocationCount == null) {
|
||||
invocationCount = myInvocationCount;
|
||||
myMap.put(result, invocationCount);
|
||||
}
|
||||
|
||||
methodName += "[" + parameters[0].toString() + " (" + INVOCATION_NUMBER + invocationCount + ")" + "]";
|
||||
if (changeCount) {
|
||||
myInvocationCount++;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ if PYVERSION > [1, 4, 0]:
|
||||
messages.testIgnored(name)
|
||||
elif report.failed:
|
||||
messages.testFailed(name, details=report.longrepr)
|
||||
messages.testFinished(name) # We need to mark it finished even if it failed to display it at parent node
|
||||
elif report.when == "call":
|
||||
messages.testFinished(name)
|
||||
|
||||
|
||||
@@ -20,10 +20,13 @@ def get_plugin_manager():
|
||||
from _pytest.core import PluginManager
|
||||
return PluginManager(load=True)
|
||||
|
||||
# "-s" is always required: no test output provided otherwise
|
||||
args = sys.argv[1:]
|
||||
args.append("-s") if "-s" not in args else None
|
||||
|
||||
if has_pytest:
|
||||
_preinit = []
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
_pluginmanager = get_plugin_manager()
|
||||
hook = _pluginmanager.hook
|
||||
try:
|
||||
@@ -38,7 +41,6 @@ if has_pytest:
|
||||
|
||||
else:
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
config = py.test.config
|
||||
try:
|
||||
config.parse(args)
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jetbrains.commandInterface.console;
|
||||
import com.intellij.execution.console.LanguageConsoleBuilder;
|
||||
import com.intellij.execution.console.LanguageConsoleImpl;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.filters.UrlFilter;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
@@ -142,6 +143,7 @@ final class CommandConsole extends LanguageConsoleImpl implements Consumer<Strin
|
||||
console.getComponent(); // For some reason console does not have component until this method is called which leads to some errros.
|
||||
console.getConsoleEditor().getSettings().setAdditionalLinesCount(2); // to prevent PY-15583
|
||||
Disposer.register(module.getProject(), console); // To dispose console when project disposes
|
||||
console.addMessageFilter(new UrlFilter());
|
||||
return console;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.filters.UrlFilter;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessTerminatedListener;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
@@ -130,6 +131,7 @@ public abstract class PythonCommandLineState extends CommandLineState {
|
||||
protected ConsoleView createAndAttachConsole(Project project, ProcessHandler processHandler, Executor executor)
|
||||
throws ExecutionException {
|
||||
final ConsoleView consoleView = createConsoleBuilder(project).getConsole();
|
||||
consoleView.addMessageFilter(new UrlFilter());
|
||||
|
||||
addTracebackFilter(project, consoleView, processHandler);
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
class TestPyTest:
|
||||
def testOne(self):
|
||||
print("I am test1")
|
||||
assert 5 == 2*2
|
||||
|
||||
def testTwo(self):
|
||||
assert True
|
||||
|
||||
def testFail(self):
|
||||
print("I will fail")
|
||||
assert False
|
||||
|
||||
def testThree():
|
||||
assert 4 == 2*2
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.jetbrains.env.python.testing;
|
||||
|
||||
import com.intellij.execution.testframework.sm.runner.ui.MockPrinter;
|
||||
import com.jetbrains.env.PyEnvTestCase;
|
||||
import com.jetbrains.env.ut.PyTestTestTask;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* User : catherine
|
||||
*/
|
||||
public class PythonPyTestingTest extends PyEnvTestCase{
|
||||
public class PythonPyTestingTest extends PyEnvTestCase {
|
||||
public void testPytestRunner() {
|
||||
runPythonTest(new PyTestTestTask("/testRunner/env/pytest", "test1.py") {
|
||||
|
||||
@@ -24,9 +27,15 @@ public class PythonPyTestingTest extends PyEnvTestCase{
|
||||
|
||||
@Override
|
||||
public void after() {
|
||||
assertEquals(8, allTestsCount());
|
||||
assertEquals(9, allTestsCount());
|
||||
assertEquals(5, passedTestsCount());
|
||||
assertEquals(3, failedTestsCount());
|
||||
assertEquals(4, failedTestsCount());
|
||||
Assert
|
||||
.assertThat("No test stdout", MockPrinter.fillPrinter(findTestByName("testOne")).getStdOut(), Matchers.startsWith("I am test1"));
|
||||
|
||||
// Ensure test has stdout even it fails
|
||||
Assert.assertThat("No stdout for fail", MockPrinter.fillPrinter(findTestByName("testFail")).getStdOut(),
|
||||
Matchers.startsWith("I will fail"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+39
-1
@@ -13,8 +13,11 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.MockPrinter;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.TestResultsViewer;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
@@ -190,7 +193,7 @@ public abstract class PyUnitTestTask extends PyExecutionFixtureTestTask {
|
||||
* Run configuration.
|
||||
*
|
||||
* @param settings settings (if have any, null otherwise)
|
||||
* @param config configuration to run
|
||||
* @param config configuration to run
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void runConfiguration(@Nullable final RunnerAndConfigurationSettings settings,
|
||||
@@ -271,6 +274,41 @@ public abstract class PyUnitTestTask extends PyExecutionFixtureTestTask {
|
||||
Assert.assertEquals(output(), 0, failedTestsCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for test by its name recursevly in {@link #myTestProxy}
|
||||
*
|
||||
* @param testName test name to find
|
||||
* @return test
|
||||
* @throws AssertionError if no test found
|
||||
*/
|
||||
@NotNull
|
||||
public AbstractTestProxy findTestByName(@NotNull final String testName) {
|
||||
final AbstractTestProxy test = findTestByName(testName, myTestProxy);
|
||||
assert test != null : "No test found with name" + testName;
|
||||
return test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for test by its name recursevly in test, passed as arumuent.
|
||||
*
|
||||
* @param testName test name to find
|
||||
* @param test root test
|
||||
* @return test or null if not found
|
||||
*/
|
||||
@Nullable
|
||||
private static AbstractTestProxy findTestByName(@NotNull final String testName, @NotNull final AbstractTestProxy test) {
|
||||
if (test.getName().equals(testName)) {
|
||||
return test;
|
||||
}
|
||||
for (final AbstractTestProxy testProxy : test.getChildren()) {
|
||||
final AbstractTestProxy result = findTestByName(testName, testProxy);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int failedTestsCount() {
|
||||
return myTestProxy.collectChildren(NOT_SUIT.and(Filter.FAILED_OR_INTERRUPTED)).size();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.intellij.spellchecker.inspector;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.spellchecker.inspections.*;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import com.intellij.util.Consumer;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -32,9 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SplitterTest extends TestCase {
|
||||
|
||||
|
||||
public class SplitterTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
public void testSplitSimpleCamelCase() {
|
||||
String text = "simpleCamelCase";
|
||||
correctListToCheck(IdentifierSplitter.getInstance(), text, "simple", "Camel", "Case");
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.xml;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.completion.InsertHandler;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.completion.PrioritizedLookupElement;
|
||||
import com.intellij.codeInsight.completion.XmlTagInsertHandler;
|
||||
@@ -100,6 +102,16 @@ public class DefaultXmlTagNameProvider implements XmlTagNameProvider {
|
||||
}
|
||||
|
||||
private static List<LookupElement> getRootTagsVariants(final XmlTag tag, final List<LookupElement> elements) {
|
||||
|
||||
elements.add(LookupElementBuilder.create("?xml version=\"1.0\" encoding=\"\" ?>").withPresentableText("<?xml version=\"1.0\" encoding=\"\" ?>").withInsertHandler(
|
||||
new InsertHandler<LookupElement>() {
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context, LookupElement item) {
|
||||
int offset = context.getEditor().getCaretModel().getOffset();
|
||||
context.getEditor().getCaretModel().moveToOffset(offset - 4);
|
||||
AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor());
|
||||
}
|
||||
}));
|
||||
final FileBasedIndex fbi = FileBasedIndex.getInstance();
|
||||
CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>();
|
||||
fbi.processAllKeys(XmlNamespaceIndex.NAME, processor, tag.getProject());
|
||||
|
||||
@@ -743,5 +743,13 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase {
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testPi() throws Exception {
|
||||
myFixture.configureByText("foo.xml", "<<caret>");
|
||||
myFixture.completeBasic();
|
||||
myFixture.type('?');
|
||||
myFixture.type('\n');
|
||||
myFixture.checkResult("<?xml version=\"1.0\" encoding=\"<caret>\" ?>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user