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:
+16
-17
@@ -28,7 +28,7 @@ import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationSession;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.ReadActionProcessor;
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -257,24 +257,23 @@ public class InspectionValidatorWrapper implements Validator {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkUnderReadAction(PsiFile file, CompileContext context, Computable<Map<ProblemDescriptor, HighlightDisplayLevel>> runnable) {
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
if (!file.isValid()) return false;
|
||||
private boolean checkUnderReadAction(final PsiFile file, final CompileContext context, final Computable<Map<ProblemDescriptor, HighlightDisplayLevel>> runnable) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
if (!file.isValid()) return false;
|
||||
|
||||
final Document document = myPsiDocumentManager.getCachedDocument(file);
|
||||
if (document != null && myPsiDocumentManager.isUncommited(document)) {
|
||||
final String url = file.getViewProvider().getVirtualFile().getUrl();
|
||||
context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1);
|
||||
return false;
|
||||
final Document document = myPsiDocumentManager.getCachedDocument(file);
|
||||
if (document != null && myPsiDocumentManager.isUncommited(document)) {
|
||||
final String url = file.getViewProvider().getVirtualFile().getUrl();
|
||||
context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reportProblems(context, runnable.compute())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (reportProblems(context, runnable.compute())) return false;
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private boolean reportProblems(CompileContext context, Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap) {
|
||||
|
||||
+2
-1
@@ -410,7 +410,8 @@ public class ProjectFromSourcesBuilderImpl extends ProjectImportBuilder implemen
|
||||
"tests".equalsIgnoreCase(name) ||
|
||||
"testSource".equalsIgnoreCase(name) ||
|
||||
"testSources".equalsIgnoreCase(name) ||
|
||||
"testSrc".equalsIgnoreCase(name);
|
||||
"testSrc".equalsIgnoreCase(name) ||
|
||||
"tst".equalsIgnoreCase(name);
|
||||
}
|
||||
|
||||
public interface ProjectConfigurationUpdater {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -65,7 +65,7 @@ public class IgnoredPatternSet {
|
||||
return fileName.endsWith(FileUtil.ASYNC_DELETE_EXTENSION);
|
||||
}
|
||||
|
||||
void clearPatterns() {
|
||||
private void clearPatterns() {
|
||||
myMasks.clear();
|
||||
myIgnorePatterns.removeAllAssociations(Boolean.TRUE);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -142,7 +142,7 @@ public class CollectHighlightsUtil {
|
||||
|
||||
PsiElement commonParent = PsiTreeUtil.findCommonParent(left, right);
|
||||
LOG.assertTrue(commonParent != null);
|
||||
LOG.assertTrue(commonParent.getTextRange() != null);
|
||||
LOG.assertTrue(commonParent.getTextRange() != null, commonParent);
|
||||
|
||||
PsiElement parent = commonParent.getParent();
|
||||
while (parent != null && commonParent.getTextRange().equals(parent.getTextRange())) {
|
||||
|
||||
@@ -224,6 +224,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
return ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiFile>() {
|
||||
@Override
|
||||
public PsiFile compute() {
|
||||
if (project.isDisposed()) return null;
|
||||
VirtualFile child;
|
||||
if (virtualFile.isValid()) {
|
||||
child = virtualFile;
|
||||
@@ -285,7 +286,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) {
|
||||
public boolean pointsToTheSameElementAs(@NotNull final SmartPointerElementInfo other) {
|
||||
if (other instanceof SelfElementInfo) {
|
||||
SelfElementInfo otherInfo = (SelfElementInfo)other;
|
||||
return Comparing.equal(myVirtualFile, otherInfo.myVirtualFile)
|
||||
@@ -296,7 +297,12 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
&& mySyncEndOffset == otherInfo.mySyncEndOffset
|
||||
;
|
||||
}
|
||||
return Comparing.equal(restoreElement(), other.restoreElement());
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return Comparing.equal(restoreElement(), other.restoreElement());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -43,7 +43,7 @@ public class InspectionDescriptionLinkHandler extends TooltipLinkHandler {
|
||||
LOG.error(editor);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (project.isDisposed()) return null;
|
||||
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
if (file == null) {
|
||||
return null;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.find.editorHeaderActions;
|
||||
|
||||
import com.intellij.find.EditorSearchComponent;
|
||||
@@ -40,7 +55,7 @@ public class FindAllAction extends EditorHeaderAction implements DumbAware {
|
||||
super.update(e);
|
||||
Editor editor = getEditorSearchComponent().getEditor();
|
||||
Project project = editor.getProject();
|
||||
if (project != null) {
|
||||
if (project != null && !project.isDisposed()) {
|
||||
e.getPresentation().setEnabled(getEditorSearchComponent().hasMatches() &&
|
||||
PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()) != null);
|
||||
}
|
||||
|
||||
+14
-10
@@ -258,11 +258,11 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
});
|
||||
files.remove(null);
|
||||
if (toLog()) {
|
||||
System.out.println("F: VFS events: " + events);
|
||||
log("F: VFS events: " + events);
|
||||
}
|
||||
if (!files.isEmpty() && RE_DETECT_ASYNC) {
|
||||
if (toLog()) {
|
||||
System.out.println("F: queued to redetect: " + files);
|
||||
log("F: queued to redetect: " + files);
|
||||
}
|
||||
reDetectQueue.offerIfAbsent(files);
|
||||
}
|
||||
@@ -277,6 +277,10 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
return RE_DETECT_ASYNC && ApplicationManager.getApplication().isUnitTestMode();
|
||||
}
|
||||
|
||||
private static void log(String message) {
|
||||
//System.out.println(message);
|
||||
}
|
||||
|
||||
private final TransferToPooledThreadQueue<Collection<VirtualFile>> reDetectQueue = new TransferToPooledThreadQueue<Collection<VirtualFile>>("File type re-detect", Conditions.alwaysFalse(), -1, new Processor<Collection<VirtualFile>>() {
|
||||
@Override
|
||||
public boolean process(Collection<VirtualFile> files) {
|
||||
@@ -306,7 +310,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
for (VirtualFile file : files) {
|
||||
boolean shouldRedetect = wasAutoDetectedBefore(file) && isDetectable(file);
|
||||
if (toLog()) {
|
||||
System.out.println("F: Redetect file: " + file.getName() + "; shouldRedetect: " + shouldRedetect);
|
||||
log("F: Redetect file: " + file.getName() + "; shouldRedetect: " + shouldRedetect);
|
||||
}
|
||||
if (shouldRedetect) {
|
||||
int id = file instanceof VirtualFileWithId ? ((VirtualFileWithId)file).getId() : -1;
|
||||
@@ -317,7 +321,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
file.putUserData(DETECTED_FROM_CONTENT_FILE_TYPE_KEY, null);
|
||||
FileType after = getFileTypeByFile(file); // may be back to standard file type
|
||||
if (toLog()) {
|
||||
System.out.println("F: After redetect file: " + file.getName() + "; before: " + before.getName() + "; after: " + after.getName()+"; now getFileType()="+file.getFileType().getName());
|
||||
log("F: After redetect file: " + file.getName() + "; before: " + before.getName() + "; after: " + after.getName()+"; now getFileType()="+file.getFileType().getName());
|
||||
}
|
||||
|
||||
if (before != after) {
|
||||
@@ -421,7 +425,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
public static void cacheFileType(@NotNull VirtualFile file, @Nullable FileType fileType) {
|
||||
file.putUserData(FILE_TYPE_KEY, fileType);
|
||||
if (toLog()) {
|
||||
System.out.println("F: Cached file type for "+file.getName()+" to "+(fileType == null ? null : fileType.getName()));
|
||||
log("F: Cached file type for "+file.getName()+" to "+(fileType == null ? null : fileType.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +445,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
FileTypeIdentifiableByVirtualFile type = mySpecialFileTypes.get(i);
|
||||
if (type.isMyFileType(file)) {
|
||||
if (toLog()) {
|
||||
System.out.println("F: Special file type for "+file.getName()+"; type: "+type.getName());
|
||||
log("F: Special file type for "+file.getName()+"; type: "+type.getName());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -450,7 +454,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
fileType = getFileTypeByFileName(file.getNameSequence());
|
||||
if (fileType != UnknownFileType.INSTANCE) {
|
||||
if (toLog()) {
|
||||
System.out.println("F: By name file type for "+file.getName()+"; type: "+fileType.getName());
|
||||
log("F: By name file type for "+file.getName()+"; type: "+fileType.getName());
|
||||
}
|
||||
return fileType;
|
||||
}
|
||||
@@ -475,7 +479,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
if (autoDetectWasRun) {
|
||||
FileType type = getAutoDetectedType(file, id);
|
||||
if (toLog()) {
|
||||
System.out.println("F: autodetected getFileType("+file.getName()+") = "+type.getName());
|
||||
log("F: autodetected getFileType("+file.getName()+") = "+type.getName());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -517,7 +521,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
if (toLog()) {
|
||||
System.out.println("F: getFileType after detect run("+file.getName()+") = "+fileType.getName());
|
||||
log("F: getFileType after detect run("+file.getName()+") = "+fileType.getName());
|
||||
}
|
||||
|
||||
return fileType;
|
||||
@@ -638,7 +642,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
FileType fileType = result.get();
|
||||
if (toLog()) {
|
||||
System.out.println("F: Redetect run for file: " + file.getName() + "; result: "+fileType.getName());
|
||||
log("F: Redetect run for file: " + file.getName() + "; result: "+fileType.getName());
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
+54
-8
@@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.welcomeScreen;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.util.io.UniqueNameBuilder;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.WelcomeScreen;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.ListWithFilter;
|
||||
@@ -25,7 +26,6 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -82,9 +82,38 @@ public class NewRecentProjectPanel extends RecentProjectPanel {
|
||||
@Override
|
||||
protected ListCellRenderer createRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
|
||||
return new RecentProjectItemRenderer(myPathShortener) {
|
||||
{
|
||||
setBorder(new EmptyBorder(0, 10, 0, 0));
|
||||
private GridBagConstraints nameCell;
|
||||
private GridBagConstraints pathCell;
|
||||
private GridBagConstraints closeButtonCell;
|
||||
|
||||
private void initConstraints () {
|
||||
nameCell = new GridBagConstraints();
|
||||
pathCell = new GridBagConstraints();
|
||||
closeButtonCell = new GridBagConstraints();
|
||||
|
||||
nameCell.gridx = 0;
|
||||
nameCell.gridy = 0;
|
||||
nameCell.weightx = 1.0;
|
||||
nameCell.weighty = 1.0;
|
||||
nameCell.anchor = GridBagConstraints.FIRST_LINE_START;
|
||||
nameCell.insets = new Insets(6, 5, 1, 5);
|
||||
|
||||
|
||||
|
||||
pathCell.gridx = 0;
|
||||
pathCell.gridy = 1;
|
||||
|
||||
pathCell.insets = new Insets(1, 5, 6, 5);
|
||||
pathCell.anchor = GridBagConstraints.LAST_LINE_START;
|
||||
|
||||
|
||||
closeButtonCell.gridx = 1;
|
||||
closeButtonCell.gridy = 0;
|
||||
closeButtonCell.gridheight = 2;
|
||||
|
||||
closeButtonCell.anchor = GridBagConstraints.WEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getListBackground(boolean isSelected, boolean hasFocus) {
|
||||
return isSelected ? FlatWelcomeFrame.getListSelectionColor(hasFocus) : FlatWelcomeFrame.getProjectsBackground();
|
||||
@@ -97,12 +126,29 @@ public class NewRecentProjectPanel extends RecentProjectPanel {
|
||||
|
||||
@Override
|
||||
protected void layoutComponents() {
|
||||
setLayout(new BorderLayout());
|
||||
myName.setBorder(new EmptyBorder(6, 0, 1, 5));
|
||||
myPath.setBorder(new EmptyBorder(1, 0, 6, 5));
|
||||
add(myName, BorderLayout.NORTH);
|
||||
add(myPath, BorderLayout.SOUTH);
|
||||
setLayout(new GridBagLayout());
|
||||
initConstraints();
|
||||
add(myName, nameCell);
|
||||
add(myPath, pathCell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
if (Registry.is("removable.welcome.screen.projects")) {
|
||||
if (myHovered) {
|
||||
add(myCloseThisItem, closeButtonCell);
|
||||
}
|
||||
else {
|
||||
remove(myCloseThisItem);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+56
-8
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl.welcomeScreen;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.RecentProjectsManagerBase;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
@@ -31,6 +32,7 @@ import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.UniqueNameBuilder;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WelcomeScreen;
|
||||
import com.intellij.ui.ClickListener;
|
||||
@@ -45,6 +47,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
@@ -53,6 +56,20 @@ import java.io.File;
|
||||
public class RecentProjectPanel extends JPanel {
|
||||
protected final JBList myList;
|
||||
protected final UniqueNameBuilder<ReopenProjectAction> myPathShortener;
|
||||
protected AnAction removeRecentProjectAction;
|
||||
private int myHoverIndex = -1;
|
||||
|
||||
private final JPanel myCloseButtonForEditor = new JPanel() {
|
||||
{
|
||||
setPreferredSize(new Dimension(AllIcons.General.BalloonClose.getIconWidth(), AllIcons.General.BalloonClose.getIconHeight()));
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
AllIcons.General.BalloonClose.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
public RecentProjectPanel(WelcomeScreen screen) {
|
||||
super(new BorderLayout());
|
||||
@@ -73,11 +90,19 @@ public class RecentProjectPanel extends JPanel {
|
||||
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
|
||||
int selectedIndex = myList.getSelectedIndex();
|
||||
if (selectedIndex >= 0) {
|
||||
if (myList.getCellBounds(selectedIndex, selectedIndex).contains(event.getPoint())) {
|
||||
Rectangle cellBounds = myList.getCellBounds(selectedIndex, selectedIndex);
|
||||
if (cellBounds.contains(event.getPoint())) {
|
||||
Object selection = myList.getSelectedValue();
|
||||
|
||||
if (selection != null) {
|
||||
((AnAction)selection).actionPerformed(AnActionEvent.createFromInputEvent((AnAction)selection, event, ActionPlaces.WELCOME_SCREEN));
|
||||
Rectangle closeButtonRect = myCloseButtonForEditor.getBounds();
|
||||
|
||||
Rectangle rectInListCoordinates = new Rectangle(new Point(closeButtonRect.x + cellBounds.x, closeButtonRect.y + cellBounds.y), closeButtonRect.getSize());
|
||||
|
||||
if (Registry.is("removable.welcome.screen.projects") && rectInListCoordinates.contains(event.getPoint())) {
|
||||
removeRecentProjectAction.actionPerformed(null);
|
||||
} else if (selection != null) {
|
||||
((AnAction)selection).actionPerformed(
|
||||
AnActionEvent.createFromInputEvent((AnAction)selection, event, ActionPlaces.WELCOME_SCREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +123,7 @@ public class RecentProjectPanel extends JPanel {
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
|
||||
|
||||
new AnAction() {
|
||||
removeRecentProjectAction = new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Object[] selection = myList.getSelectedValues();
|
||||
@@ -128,7 +153,8 @@ public class RecentProjectPanel extends JPanel {
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(!ListWithFilter.isSearchActive(myList));
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), myList, screen);
|
||||
};
|
||||
removeRecentProjectAction.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), myList, screen);
|
||||
|
||||
addMouseMotionListener();
|
||||
|
||||
@@ -167,8 +193,10 @@ public class RecentProjectPanel extends JPanel {
|
||||
}
|
||||
|
||||
protected void addMouseMotionListener() {
|
||||
myList.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
|
||||
MouseAdapter mouseAdapter = new MouseAdapter() {
|
||||
boolean myIsEngaged = false;
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
|
||||
Point point = e.getPoint();
|
||||
@@ -178,16 +206,30 @@ public class RecentProjectPanel extends JPanel {
|
||||
final Rectangle bounds = myList.getCellBounds(index, index);
|
||||
if (bounds != null && bounds.contains(point)) {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
myHoverIndex = index;
|
||||
myList.repaint(bounds);
|
||||
}
|
||||
else {
|
||||
myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
myHoverIndex = -1;
|
||||
myList.repaint();
|
||||
}
|
||||
}
|
||||
else {
|
||||
myIsEngaged = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
myHoverIndex = -1;
|
||||
myList.repaint();
|
||||
}
|
||||
};
|
||||
|
||||
myList.addMouseMotionListener(mouseAdapter);
|
||||
myList.addMouseListener(mouseAdapter);
|
||||
|
||||
}
|
||||
|
||||
protected JBList createList(AnAction[] recentProjectActions, Dimension size) {
|
||||
@@ -232,9 +274,13 @@ public class RecentProjectPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
protected static class RecentProjectItemRenderer extends JPanel implements ListCellRenderer {
|
||||
protected class RecentProjectItemRenderer extends JPanel implements ListCellRenderer {
|
||||
|
||||
protected final JLabel myName = new JLabel();
|
||||
protected final JLabel myPath = new JLabel();
|
||||
protected boolean myHovered;
|
||||
protected JPanel myCloseThisItem = myCloseButtonForEditor;
|
||||
|
||||
private final UniqueNameBuilder<ReopenProjectAction> myShortener;
|
||||
|
||||
protected RecentProjectItemRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
|
||||
@@ -260,6 +306,8 @@ public class RecentProjectPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
myHovered = myHoverIndex == index;
|
||||
|
||||
ReopenProjectAction item = (ReopenProjectAction)value;
|
||||
|
||||
Color fore = getListForeground(isSelected, list.hasFocus());
|
||||
|
||||
+41
-35
@@ -40,6 +40,7 @@ import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import junit.framework.TestCase;
|
||||
@@ -104,7 +105,27 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
}
|
||||
|
||||
public void testExcludePerformance() {
|
||||
runPerformanceTest(true);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myFileTypeManager.setIgnoredFilesList("1*2;3*4;5*6;7*8;9*0;*1;*3;*5;*6;7*;*8*");
|
||||
}
|
||||
});
|
||||
final String[] names = new String[100];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
String name = String.valueOf((i%10)*10 + (i*100) + i + 1);
|
||||
names[i] = (name + name + name + name);
|
||||
}
|
||||
PlatformTestUtil.startPerformanceTest("ignore perf", 700, new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
for (int i=0;i<1000;i++) {
|
||||
for (String name : names) {
|
||||
myFileTypeManager.isFileIgnored(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).assertTiming();
|
||||
}
|
||||
|
||||
public void testMaskToPattern() {
|
||||
@@ -174,25 +195,6 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
assertTrue(myFileTypeManager.isFileIgnored(fileName));
|
||||
}
|
||||
|
||||
private void runPerformanceTest(boolean rerunOnOvertime) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myFileTypeManager.setIgnoredFilesList("1*2;3*4;5*6;7*8;9*0;*1;*3;*5;*6;7*;*8*");
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String name = String.valueOf((i%10)*10 + (i*100) + i + 1);
|
||||
myFileTypeManager.isFileIgnored(name + name + name + name);
|
||||
}
|
||||
long time = System.currentTimeMillis() - startTime;
|
||||
if (time > 700) {
|
||||
if (rerunOnOvertime) runPerformanceTest(false);
|
||||
else fail("Time=" + time);
|
||||
}
|
||||
}
|
||||
|
||||
public void testAutoDetected() throws IOException {
|
||||
File dir = createTempDirectory();
|
||||
File file = FileUtil.createTempFile(dir, "x", "xxx_xx_xx", true);
|
||||
@@ -311,7 +313,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
detectorCalled.add(file);
|
||||
String text = firstCharsIfText.toString();
|
||||
FileType result = text.startsWith("TYPE:") ? fileTypeManager.findFileTypeByName(StringUtil.trimStart(text, "TYPE:")) : null;
|
||||
System.out.println("T: my detector run for "+file.getName()+"; result: "+(result == null ? null : result.getName()));
|
||||
log("T: my detector run for "+file.getName()+"; result: "+(result == null ? null : result.getName()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -322,42 +324,46 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
};
|
||||
Extensions.getRootArea().getExtensionPoint(FileTypeRegistry.FileTypeDetector.EP_NAME).registerExtension(detector);
|
||||
try {
|
||||
System.out.println("T: ------");
|
||||
log("T: ------");
|
||||
File f = createTempFile("xx.asfdasdfas", "akjdhfksdjgf");
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof PlainTextFileType);
|
||||
|
||||
System.out.println("T: ------");
|
||||
log("T: ------");
|
||||
VfsUtil.saveText(vFile, "TYPE:IDEA_MODULE");
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ModuleFileType);
|
||||
|
||||
System.out.println("T: ------");
|
||||
log("T: ------");
|
||||
VfsUtil.saveText(vFile, "TYPE:IDEA_PROJECT");
|
||||
ensureRedetected(vFile, detectorCalled);
|
||||
assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ProjectFileType);
|
||||
System.out.println("T: ------");
|
||||
log("T: ------");
|
||||
}
|
||||
finally {
|
||||
Extensions.getRootArea().getExtensionPoint(FileTypeRegistry.FileTypeDetector.EP_NAME).unregisterExtension(detector);
|
||||
}
|
||||
}
|
||||
|
||||
private static void log(String message) {
|
||||
//System.out.println(message);
|
||||
}
|
||||
|
||||
private void ensureRedetected(VirtualFile vFile, Set<VirtualFile> detectorCalled) {
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
System.out.println("T: ensureRedetected: commit");
|
||||
log("T: ensureRedetected: commit");
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
System.out.println("T: ensureRedetected: dispatch");
|
||||
log("T: ensureRedetected: dispatch");
|
||||
myFileTypeManager.drainReDetectQueue();
|
||||
System.out.println("T: ensureRedetected: drain");
|
||||
log("T: ensureRedetected: drain");
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
System.out.println("T: ensureRedetected: dispatch");
|
||||
log("T: ensureRedetected: dispatch");
|
||||
FileType type = vFile.getFileType();
|
||||
System.out.println("T: ensureRedetected: getFileType ("+type.getName()+")");
|
||||
log("T: ensureRedetected: getFileType ("+type.getName()+")");
|
||||
assertTrue(detectorCalled.contains(vFile));
|
||||
detectorCalled.clear();
|
||||
System.out.println("T: ensureRedetected: clear");
|
||||
log("T: ensureRedetected: clear");
|
||||
}
|
||||
|
||||
public void testReassignedPredefinedFileType() throws Exception {
|
||||
@@ -404,7 +410,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
Element element = new Element("foo");
|
||||
myFileTypeManager.writeExternal(element);
|
||||
String s = JDOMUtil.writeElement(element);
|
||||
System.out.println(s);
|
||||
log(s);
|
||||
|
||||
final AbstractFileType typeFromPlugin = new AbstractFileType(new SyntaxTable());
|
||||
PlatformTestUtil.registerExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, new FileTypeFactory() {
|
||||
@@ -453,7 +459,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
|
||||
element = new Element("foo");
|
||||
myFileTypeManager.writeExternal(element);
|
||||
System.out.println(JDOMUtil.writeElement(element));
|
||||
log(JDOMUtil.writeElement(element));
|
||||
|
||||
Extensions.getRootArea().getExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP).unregisterExtension(factory);
|
||||
myFileTypeManager.clearForTests();
|
||||
@@ -463,7 +469,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
|
||||
element = new Element("foo");
|
||||
myFileTypeManager.writeExternal(element);
|
||||
System.out.println(JDOMUtil.writeElement(element));
|
||||
log(JDOMUtil.writeElement(element));
|
||||
|
||||
Extensions.getRootArea().getExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP).registerExtension(factory);
|
||||
myFileTypeManager.clearForTests();
|
||||
@@ -473,7 +479,7 @@ public class FileTypesTest extends PlatformTestCase {
|
||||
|
||||
element = new Element("foo");
|
||||
myFileTypeManager.writeExternal(element);
|
||||
System.out.println(JDOMUtil.writeElement(element));
|
||||
log(JDOMUtil.writeElement(element));
|
||||
|
||||
assertEquals(typeFromPlugin, myFileTypeManager.getFileTypeByFileName("foo.foo"));
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTestCase {
|
||||
public abstract class LightPlatformCodeInsightTestCase extends LightPlatformLangTestCase {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.testFramework.LightCodeInsightTestCase");
|
||||
|
||||
protected static Editor myEditor;
|
||||
|
||||
@@ -515,4 +515,7 @@ force.subpixel.hinting=false
|
||||
force.subpixel.hinting.description=Force using sub-pixel antialiasing
|
||||
|
||||
lcd.contrast.value=140
|
||||
lcd.contrast.value.description=Set LCD text contrast value from 100 to 250
|
||||
lcd.contrast.value.description=Set LCD text contrast value from 100 to 250
|
||||
|
||||
removable.welcome.screen.projects=false
|
||||
removable.welcomesreen.projects.description=Allows removing recent projects from welcome screen with mouse
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -28,6 +29,8 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator {
|
||||
private final Map<VirtualFile, PackageAnnotator.PackageCoverageInfo> myTestDirCoverageInfos =
|
||||
new HashMap<VirtualFile, PackageAnnotator.PackageCoverageInfo>();
|
||||
private final Map<String, PackageAnnotator.ClassCoverageInfo> myClassCoverageInfos = new HashMap<String, PackageAnnotator.ClassCoverageInfo>();
|
||||
private final WeakHashMap<PsiElement, PackageAnnotator.SummaryCoverageInfo> myExtensionCoverageInfos =
|
||||
new WeakHashMap<PsiElement, PackageAnnotator.SummaryCoverageInfo>();
|
||||
|
||||
public JavaCoverageAnnotator(final Project project) {
|
||||
super(project);
|
||||
@@ -71,6 +74,7 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator {
|
||||
myDirCoverageInfos.clear();
|
||||
myTestDirCoverageInfos.clear();
|
||||
myClassCoverageInfos.clear();
|
||||
myExtensionCoverageInfos.clear();
|
||||
}
|
||||
|
||||
protected Runnable createRenewRequest(@NotNull final CoverageSuitesBundle suite, @NotNull final CoverageDataManager dataManager) {
|
||||
@@ -257,4 +261,20 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator {
|
||||
public PackageAnnotator.ClassCoverageInfo getClassCoverageInfo(String classFQName) {
|
||||
return myClassCoverageInfos.get(classFQName);
|
||||
}
|
||||
|
||||
public PackageAnnotator.SummaryCoverageInfo getExtensionCoverageInfo(PsiNamedElement value) {
|
||||
PackageAnnotator.SummaryCoverageInfo cachedInfo = myExtensionCoverageInfos.get(value);
|
||||
if (cachedInfo != null) {
|
||||
return cachedInfo;
|
||||
}
|
||||
for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) {
|
||||
PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(this, value);
|
||||
if (info != null) {
|
||||
myExtensionCoverageInfos.put(value, info);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,16 @@ public abstract class JavaCoverageEngineExtension {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified .class file needs to be completely excluded from the coverage statistics.
|
||||
*
|
||||
* @param bundle the coverage suites bundle being indexed.
|
||||
* @param classFile the class file.
|
||||
*/
|
||||
public boolean ignoreCoverageForClass(CoverageSuitesBundle bundle, File classFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the class coverage info for the specified .class file, for which it wasn't possible to find a corresponding
|
||||
* source file, needs to be preserved and made available as {@link JavaCoverageAnnotator#getClassCoverageInfo(String)}.
|
||||
|
||||
@@ -311,20 +311,27 @@ public class PackageAnnotator {
|
||||
}
|
||||
});
|
||||
PackageCoverageInfo coverageInfoForClass = null;
|
||||
if (isInSource != null && isInSource.booleanValue()) {
|
||||
String classCoverageKey = classFqVMName.replace('/', '.');
|
||||
boolean ignoreClass = false;
|
||||
for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.ignoreCoverageForClass(myCoverageManager.getCurrentSuitesBundle(), child)) {
|
||||
ignoreClass = true;
|
||||
break;
|
||||
}
|
||||
if (extension.keepCoverageInfoForClassWithoutSource(myCoverageManager.getCurrentSuitesBundle(), child)) {
|
||||
coverageInfoForClass = classWithoutSourceCoverageInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ignoreClass) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (coverageInfoForClass == null && isInSource != null && isInSource.booleanValue()) {
|
||||
for (DirCoverageInfo dirCoverageInfo : dirs) {
|
||||
if (dirCoverageInfo.sourceRoot != null && VfsUtil.isAncestor(dirCoverageInfo.sourceRoot, containingFileRef.get(), false)) {
|
||||
coverageInfoForClass = dirCoverageInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String classCoverageKey = toplevelClassSrcFQName;
|
||||
if (coverageInfoForClass == null) {
|
||||
for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.keepCoverageInfoForClassWithoutSource(myCoverageManager.getCurrentSuitesBundle(), child)) {
|
||||
classCoverageKey = classFqVMName.replace('/', '.');
|
||||
coverageInfoForClass = classWithoutSourceCoverageInfo;
|
||||
classCoverageKey = toplevelClassSrcFQName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -411,7 +418,7 @@ public class PackageAnnotator {
|
||||
boolean touchedClass = false;
|
||||
final Collection methodSigs = classData.getMethodSigs();
|
||||
for (final Object nameAndSig : methodSigs) {
|
||||
if (isGeneratedDefaultConstructor(psiClass, (String) nameAndSig)) {
|
||||
if (isGeneratedDefaultConstructor(psiClass, (String)nameAndSig)) {
|
||||
continue;
|
||||
}
|
||||
final int covered = classData.getStatus((String)nameAndSig);
|
||||
@@ -431,14 +438,21 @@ public class PackageAnnotator {
|
||||
packageCoverageInfo.coveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount;
|
||||
packageCoverageInfo.coveredMethodCount += toplevelClassCoverageInfo.coveredMethodCount;
|
||||
packageCoverageInfo.totalMethodCount += toplevelClassCoverageInfo.totalMethodCount;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOG.debug("Did not find any method signatures in " + classFile.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!collectNonCoveredClassInfo(classFile, psiClass, toplevelClassCoverageInfo, packageCoverageInfo)) {
|
||||
LOG.debug("Did not collect non-covered class info for " + classFile.getName());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!collectNonCoveredClassInfo(classFile, psiClass, toplevelClassCoverageInfo, packageCoverageInfo)) return;
|
||||
}
|
||||
|
||||
ClassCoverageInfo classCoverageInfo = getOrCreateClassCoverageInfo(toplevelClassCoverage, toplevelClassSrcFQName);
|
||||
LOG.debug("Adding coverage of " + classFile.getName() + " to top-level class " + toplevelClassSrcFQName);
|
||||
classCoverageInfo.totalLineCount += toplevelClassCoverageInfo.totalLineCount;
|
||||
classCoverageInfo.fullyCoveredLineCount += toplevelClassCoverageInfo.fullyCoveredLineCount;
|
||||
classCoverageInfo.partiallyCoveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SourceLineCounterUtil {
|
||||
if (!counter.isInterface()) {
|
||||
packageCoverageInfo.totalClassCount++;
|
||||
}
|
||||
return true;
|
||||
return !counter.isInterface();
|
||||
}
|
||||
|
||||
public static void collectSrcLinesForUntouchedFiles(final List<Integer> uncoveredLines,
|
||||
|
||||
@@ -90,12 +90,7 @@ public class JavaCoverageViewExtension extends CoverageViewExtension {
|
||||
return myAnnotator.getPackageCoverageInfo((PsiPackage)value, myStateBean.myFlattenPackages);
|
||||
}
|
||||
if (value instanceof PsiNamedElement) {
|
||||
for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) {
|
||||
PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(myAnnotator, (PsiNamedElement)value);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return myAnnotator.getExtensionCoverageInfo((PsiNamedElement) value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -175,8 +175,14 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType {
|
||||
@Nullable
|
||||
public static String getBuildNumber(String ideaHome) {
|
||||
try {
|
||||
@NonNls final String buildTxt = SystemInfo.isMac ? "/Resources/build.txt" : "/build.txt";
|
||||
return FileUtil.loadFile(new File(ideaHome + buildTxt)).trim();
|
||||
@NonNls final String buildTxt = SystemInfo.isMac ? "Resources/build.txt" : "build.txt";
|
||||
File file = new File(ideaHome, buildTxt);
|
||||
if (SystemInfo.isMac && !file.exists()) {
|
||||
// IntelliJ IDEA 13 and earlier used a different location for build.txt on Mac;
|
||||
// recognize the old location as well
|
||||
file = new File(ideaHome, "build.txt");
|
||||
}
|
||||
return FileUtil.loadFile(file).trim();
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
@@ -210,7 +216,9 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType {
|
||||
for (File jar : jars) {
|
||||
@NonNls String name = jar.getName();
|
||||
if (jar.isFile() && Arrays.binarySearch(forbidden, name) < 0 && (name.endsWith(".jar") || name.endsWith(".zip"))) {
|
||||
result.add(jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR));
|
||||
VirtualFile file = jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR);
|
||||
LOG.assertTrue(file != null, jar.getPath() + " not found");
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ class _BehaveRunner(_bdd_utils.BddRunner):
|
||||
:return true if should pass
|
||||
"""
|
||||
assert isinstance(scenario, Scenario), scenario
|
||||
# TODO: share with lettuce_runner.py#_get_features_to_run
|
||||
expected_tags = self.__config.tags
|
||||
scenario_name_re = self.__config.name_re
|
||||
if scenario_name_re and not scenario_name_re.match(scenario.name):
|
||||
|
||||
@@ -4,7 +4,7 @@ BDD lettuce framework runner
|
||||
TODO: Support other params (like tags) as well.
|
||||
Supports only 2 params now: folder to search "features" for or file and "-s scenario_index"
|
||||
"""
|
||||
import argparse
|
||||
import inspect
|
||||
import optparse
|
||||
import os
|
||||
import _bdd_utils
|
||||
@@ -28,25 +28,31 @@ class _LettuceRunner(_bdd_utils.BddRunner):
|
||||
:param base_dir base directory to run tests in
|
||||
:type base_dir: str
|
||||
:param what_to_run folder or file to run
|
||||
:type options list of optparse.Option
|
||||
:type options optparse.Values
|
||||
:param options optparse options passed by user
|
||||
:type what_to_run str
|
||||
|
||||
"""
|
||||
super(_LettuceRunner, self).__init__(base_dir)
|
||||
# TODO: Copy/Paste with lettuce.bin, need to reuse somehow
|
||||
tags = None
|
||||
if options.tags:
|
||||
tags = [tag.strip('@') for tag in options.tags]
|
||||
self.__runner = lettuce.Runner(what_to_run, ",".join(scenarios),
|
||||
random=options.random,
|
||||
enable_xunit=options.enable_xunit,
|
||||
xunit_filename=options.xunit_file,
|
||||
enable_subunit=options.enable_subunit,
|
||||
subunit_filename=options.subunit_filename,
|
||||
failfast=options.failfast,
|
||||
auto_pdb=options.auto_pdb,
|
||||
tags=tags)
|
||||
|
||||
# Delete args that do not exist in constructor
|
||||
args_to_pass = options.__dict__
|
||||
runner_args = inspect.getargspec(lettuce.Runner.__init__)[0]
|
||||
unknown_args = set(args_to_pass.keys()) - set(runner_args)
|
||||
map(args_to_pass.__delitem__, unknown_args)
|
||||
|
||||
# Tags is special case and need to be preprocessed
|
||||
self.__tags = None # Store tags in field
|
||||
if 'tags' in args_to_pass.keys() and args_to_pass['tags']:
|
||||
args_to_pass['tags'] = [tag.strip('@') for tag in args_to_pass['tags']]
|
||||
self.__tags = set(args_to_pass['tags'])
|
||||
|
||||
# Special cases we pass directly
|
||||
args_to_pass['base_path'] = what_to_run
|
||||
args_to_pass['scenarios'] = ",".join(scenarios)
|
||||
|
||||
self.__runner = lettuce.Runner(**args_to_pass)
|
||||
|
||||
def _get_features_to_run(self):
|
||||
super(_LettuceRunner, self)._get_features_to_run()
|
||||
@@ -71,6 +77,11 @@ class _LettuceRunner(_bdd_utils.BddRunner):
|
||||
if index < len(feature.scenarios):
|
||||
filtered_feature_scenarios.append(feature.scenarios[index])
|
||||
feature.scenarios = filtered_feature_scenarios
|
||||
|
||||
# Filter out tags TODO: Share with behave_runner.py#__filter_scenarios_by_args
|
||||
if self.__tags:
|
||||
for feature in features:
|
||||
feature.scenarios = filter(lambda s: set(s.tags) & self.__tags, feature.scenarios)
|
||||
return features
|
||||
|
||||
def _run_tests(self):
|
||||
@@ -145,7 +156,7 @@ def _get_args():
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbosity",
|
||||
dest="verbosity",
|
||||
default=4,
|
||||
default=0, # We do not need verbosity due to GUI we use (although user may override it)
|
||||
help='The verbosity level')
|
||||
|
||||
parser.add_option("-s", "--scenarios",
|
||||
|
||||
Reference in New Issue
Block a user