Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2014-07-31 16:44:49 +04:00
141 changed files with 1761 additions and 698 deletions
@@ -19,16 +19,29 @@ import com.intellij.extapi.psi.PsiFileBase;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.lang.regexp.psi.RegExpGroup;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public class RegExpFile extends PsiFileBase {
public RegExpFile(FileViewProvider viewProvider, final Language language) {
super(viewProvider, language);
}
public RegExpFile(FileViewProvider viewProvider, final Language language) {
super(viewProvider, language);
}
@NotNull
public FileType getFileType() {
return RegExpFileType.INSTANCE;
}
@NotNull
public FileType getFileType() {
return RegExpFileType.INSTANCE;
}
/**
* @return Regexp groups this file has
*/
@NotNull
public Collection<RegExpGroup> getGroups() {
return PsiTreeUtil.findChildrenOfType(this, RegExpGroup.class);
}
}
+1
View File
@@ -562,6 +562,7 @@ ${If} $8 > $control_fields
StrCpy $2 ""
!insertmacro MUI_HEADER_TEXT "$(uninstall_previous_installations_title)" "$(uninstall_previous_installations)"
!insertmacro INSTALLOPTIONS_WRITE "UninstallOldVersions.ini" "Field 1" "Text" "$(uninstall_previous_installations_prompt)"
!insertmacro INSTALLOPTIONS_WRITE "UninstallOldVersions.ini" "Field 3" "Flags" "FOCUS"
!insertmacro INSTALLOPTIONS_DISPLAY "UninstallOldVersions.ini"
;uninstall chosen installation(s)
+1
View File
@@ -51,6 +51,7 @@ target('run_tests': 'Run java tests') {
pass("idea.test.group")
pass("idea.test.patterns")
pass("idea.fast.only")
pass("idea.coverage.enabled.build")
pass("teamcity.build.tempDir")
pass("teamcity.tests.recentlyFailedTests.file")
jvmarg(value: "-Didea.platform.prefix=Idea")
@@ -110,7 +110,9 @@ public class JavaEditorTextProviderImpl implements EditorTextProvider {
else if (parent instanceof PsiInstanceOfExpression
|| parent instanceof PsiBinaryExpression
|| parent instanceof PsiPolyadicExpression
|| parent instanceof PsiPrefixExpression) {
|| parent instanceof PsiPrefixExpression
|| parent instanceof PsiConditionalExpression
) {
if (allowMethodCalls || !DebuggerUtils.hasSideEffects(parent)) {
expression = parent;
}
@@ -63,6 +63,6 @@ public class XBreakpointGroupingByPackageRule<B> extends XBreakpointGroupingRule
@Nullable
@Override
public Icon getIcon() {
return AllIcons.Nodes.Package;
return AllIcons.Actions.GroupByPackage;
}
}
@@ -51,7 +51,7 @@ public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!shouldCreateRequest(debugProcess)) {
return;
}
super.processClassPrepare(debugProcess, null);
@@ -46,6 +46,7 @@ import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.XDebuggerHistoryManager;
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase;
@@ -95,7 +96,15 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
* Request for creating all needed JPDA requests in the specified VM
* @param debuggerProcess the requesting process
*/
public abstract void createRequest(DebugProcessImpl debuggerProcess);
public abstract void createRequest(DebugProcessImpl debugProcess);
protected boolean shouldCreateRequest(DebugProcessImpl debugProcess) {
JavaDebugProcess process = debugProcess.getXdebugProcess();
return process != null
&& debugProcess.isAttached()
&& ((XDebugSessionImpl)process.getSession()).isBreakpointActive(myXBreakpoint)
&& debugProcess.getRequestsManager().findRequests(this).isEmpty();
}
/**
* Request for creating all needed JPDA requests in the specified VM
@@ -17,10 +17,7 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.CommonBundle;
import com.intellij.debugger.*;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.debugger.engine.*;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
@@ -300,10 +297,7 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
public void createRequest(@NotNull DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
// check is this breakpoint is enabled, vm reference is valid and there're no requests created yet
if (!isEnabled() ||
!debugProcess.isAttached() ||
isMuted(debugProcess) ||
!debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!shouldCreateRequest(debugProcess)) {
return;
}
@@ -118,7 +118,7 @@ public class ExceptionBreakpoint extends Breakpoint<JavaExceptionBreakpointPrope
public void createRequest(final DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!shouldCreateRequest(debugProcess)) {
return;
}
@@ -123,4 +123,9 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return new RunToCursorBreakpoint(project, pos, restoreBreakpoints);
}
@Override
protected boolean shouldCreateRequest(DebugProcessImpl debugProcess) {
return debugProcess.isAttached() && debugProcess.getRequestsManager().findRequests(this).isEmpty();
}
}
@@ -129,7 +129,7 @@ public class WildcardMethodBreakpoint extends Breakpoint<JavaMethodBreakpointPro
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!shouldCreateRequest(debugProcess)) {
return;
}
try {
@@ -293,6 +293,11 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
return handler;
}
@Override
protected boolean ansiColoringEnabled() {
return true;
}
protected ApplicationConfiguration getConfiguration() {
return myConfiguration;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -140,6 +141,7 @@ public class JavaContentEntriesEditor extends CommonContentEntriesEditor {
@Override
protected JPanel createBottomControl(Module module) {
if (Registry.is("ide.new.project.settings")) return null;
final JPanel innerPanel = new JPanel(new GridBagLayout());
innerPanel.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 6));
return innerPanel;
@@ -38,7 +38,6 @@ import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.ui.TreeSpeedSearch;
@@ -302,7 +301,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
result.addAll(copyActions);
result.add(Separator.getInstance());
if (fromPopup || !(SystemInfo.isMac && Registry.is("ide.new.project.settings"))) {
if (fromPopup || !Registry.is("ide.new.project.settings")) {
result.add(new MyFindUsagesAction(myTree));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -35,6 +35,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.FacetProje
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
import com.intellij.openapi.ui.DetailsComponent;
import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
import com.intellij.util.ui.tree.TreeUtil;
@@ -277,8 +278,10 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable {
actions.add(new MyNavigateAction());
}
actions.add(new MyRemoveAction());
actions.add(Separator.getInstance());
addCollapseExpandActions(actions);
if (fromPopup || !(Registry.is("ide.new.project.settings"))) {
actions.add(Separator.getInstance());
addCollapseExpandActions(actions);
}
return actions;
}
@@ -53,7 +53,6 @@ import com.intellij.openapi.ui.*;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
@@ -149,9 +148,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
@NotNull
protected ArrayList<AnAction> createActions(final boolean fromPopup) {
final ArrayList<AnAction> result = super.createActions(fromPopup);
result.add(Separator.getInstance());
result.add(new MyGroupAction());
if (fromPopup || !(SystemInfo.isMac && Registry.is("ide.new.project.settings"))) {
if (fromPopup || !Registry.is("ide.new.project.settings")) {
result.add(Separator.getInstance());
result.add(new MyGroupAction());
addCollapseExpandActions(result);
}
return result;
@@ -16,7 +16,6 @@
package com.intellij.psi.impl.source.resolve.reference.impl.providers;
import com.intellij.psi.*;
import com.intellij.psi.jsp.JspImplicitVariable;
import com.intellij.psi.jsp.JspSpiUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.xml.XmlAttribute;
@@ -62,8 +61,8 @@ public class MethodPropertyReference extends BasicAttributeValueReference {
}
} else if (psiElement instanceof PsiClass) {
return (PsiClass)psiElement;
} else if (psiElement instanceof JspImplicitVariable) {
final PsiType type=((JspImplicitVariable)psiElement).getType();
} else if (psiElement instanceof PsiVariable) {
final PsiType type=((PsiVariable)psiElement).getType();
if (type instanceof PsiClassType) {
return ((PsiClassType)type).resolve();
}
@@ -579,7 +579,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String text = "/** done done done */";
findModel.setInCommentsOnly(true);
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text);
findModel.setRegularExpressions(true);
@@ -592,7 +592,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
String prefix = "/*";
String text = prefix + "done*/";
findModel.setInCommentsOnly(true);
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
@@ -615,8 +615,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
findModel.setRegularExpressions(true);
findModel.setInStringLiteralsOnly(true);
findModel.setInCommentsOnly(false);
findModel.setSearchContext(FindModel.SearchContext.IN_STRINGS);
String text = "\"done\"; 'done'; 'done' \"done2\"";
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
@@ -633,7 +632,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
String text = "/** do ne do ne do ne */";
findModel.setInCommentsOnly(true);
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
}
@@ -21,9 +21,6 @@ import com.intellij.psi.JavaElementVisitor;
* @author yole
*/
public abstract class JavaJspElementVisitor extends JavaElementVisitor {
public void visitJspImplicitVariable(JspImplicitVariable variable){
visitImplicitVariable(variable);
}
public void visitJspFile(JspFile jspFile) {
visitFile(jspFile);
@@ -24,12 +24,10 @@ public class FindManagerTestUtils {
}
public static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text, String ext) {
findModel.setInStringLiteralsOnly(true);
findModel.setInCommentsOnly(false);
findModel.setSearchContext(FindModel.SearchContext.IN_STRINGS);
runFindForwardAndBackward(findManager, findModel, text, ext);
findModel.setInStringLiteralsOnly(false);
findModel.setInCommentsOnly(true);
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
runFindForwardAndBackward(findManager, findModel, text, ext);
}
@@ -47,7 +47,7 @@ public class FileContent extends UserDataHolderBase {
@NotNull
public byte[] getBytes() throws IOException {
if (myCachedBytes == null) {
myCachedBytes = myVirtualFile.contentsToByteArray(false);
myCachedBytes = myVirtualFile.isValid() ? myVirtualFile.contentsToByteArray(false) : ArrayUtil.EMPTY_BYTE_ARRAY;
}
return myCachedBytes;
@@ -84,6 +84,20 @@ public class VfsUtilCore {
return false;
}
/**
* @return {@code true} if {@code url} is located under one of {@code rootUrls} or equal to one of them
*/
public static boolean isUnder(@NotNull String url, @Nullable Collection<String> rootUrls) {
if (rootUrls == null || rootUrls.isEmpty()) return false;
for (String excludesUrl : rootUrls) {
if (isEqualOrAncestor(excludesUrl, url)) {
return true;
}
}
return false;
}
public static boolean isEqualOrAncestor(@NotNull String ancestorUrl, @NotNull String fileUrl) {
if (ancestorUrl.equals(fileUrl)) return true;
if (StringUtil.endsWithChar(ancestorUrl, '/')) {
@@ -33,8 +33,13 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -151,7 +156,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true, createEmptyContentRootDirectories);
}
for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) {
createExcludedRootIfAbsent(contentEntry, path, module.getName());
createExcludedRootIfAbsent(contentEntry, path, module.getName(), module.getProject());
}
contentEntriesMap.remove(contentEntry.getUrl());
}
@@ -214,14 +219,18 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
}
}
private static void createExcludedRootIfAbsent(@NotNull ContentEntry entry, @NotNull SourceRoot root, @NotNull String moduleName) {
private static void createExcludedRootIfAbsent(@NotNull ContentEntry entry, @NotNull SourceRoot root, @NotNull String moduleName, @NotNull Project project) {
String rootPath = root.getPath();
for (VirtualFile file : entry.getExcludeFolderFiles()) {
if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(rootPath)) {
return;
}
}
LOG.info(String.format("Importing excluded root '%s' for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
entry.addExcludeFolder(toVfsUrl(root.getPath()));
entry.addExcludeFolder(toVfsUrl(rootPath));
if (!Registry.is("ide.hide.excluded.files")) {
ChangeListManager.getInstance(project).addDirectoryToIgnoreImplicitly(rootPath);
}
}
@Override
Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

@@ -76,7 +76,7 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
}
private GlobalSearchScope getDefaultResolveScope(@NotNull PsiFile psiFile, @NotNull final VirtualFile vFile) {
private GlobalSearchScope getResolveScopeFromProviders(@NotNull final VirtualFile vFile) {
return myDefaultResolveScopesCache.get(vFile);
}
@@ -85,8 +85,6 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
Module module = projectFileIndex.getModuleForFile(vFile);
if (module != null) {
boolean includeTests = projectFileIndex.isInTestSourceContent(vFile);
// TODO: dmitrylomov: removed this line to see what fails.
//!(vFile.getFileType() == StdFileTypes.JAVA && projectFileIndex.isContentSourceFile(vFile));
return GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, includeTests);
}
else {
@@ -167,7 +165,7 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
return GlobalSearchScope.allScope(myProject);
}
return getDefaultResolveScope(contextFile, vFile);
return getResolveScopeFromProviders(vFile);
}
@@ -175,7 +173,7 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
public GlobalSearchScope getDefaultResolveScope(final VirtualFile vFile) {
final PsiFile psiFile = myManager.findFile(vFile);
assert psiFile != null;
return getDefaultResolveScope(psiFile, vFile);
return getResolveScopeFromProviders(vFile);
}
@@ -72,8 +72,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
private boolean isSearchHighlighters = false;
private boolean isReplaceState = false;
private boolean isWholeWordsOnly = false;
private boolean isInCommentsOnly;
private boolean isInStringLiteralsOnly;
private SearchContext searchContext = SearchContext.ANY;
private boolean isFromCursor = true;
private boolean isForward = true;
private boolean isGlobal = true;
@@ -171,8 +170,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
isCustomScope = model.isCustomScope;
isFindAll = model.isFindAll;
isInCommentsOnly = model.isInCommentsOnly;
isInStringLiteralsOnly = model.isInStringLiteralsOnly;
searchContext = model.searchContext;
isMultiline = model.isMultiline;
}
@@ -191,8 +189,8 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
if (isForward != findModel.isForward) return false;
if (isFromCursor != findModel.isFromCursor) return false;
if (isGlobal != findModel.isGlobal) return false;
if (isInCommentsOnly != findModel.isInCommentsOnly) return false;
if (isInStringLiteralsOnly != findModel.isInStringLiteralsOnly) return false;
if (searchContext != findModel.searchContext) return false;
if (isMultiline != findModel.isMultiline) return false;
if (isMultipleFiles != findModel.isMultipleFiles) return false;
if (isOpenInNewTabEnabled != findModel.isOpenInNewTabEnabled) return false;
@@ -229,8 +227,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
result = 31 * result + (isSearchHighlighters ? 1 : 0);
result = 31 * result + (isReplaceState ? 1 : 0);
result = 31 * result + (isWholeWordsOnly ? 1 : 0);
result = 31 * result + (isInCommentsOnly ? 1 : 0);
result = 31 * result + (isInStringLiteralsOnly ? 1 : 0);
result = 31 * result + (searchContext.ordinal());
result = 31 * result + (isFromCursor ? 1 : 0);
result = 31 * result + (isForward ? 1 : 0);
result = 31 * result + (isGlobal ? 1 : 0);
@@ -673,8 +670,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
buffer.append("myStringToReplace =").append(myStringToReplace).append("\n");
buffer.append("isReplaceState =").append(isReplaceState).append("\n");
buffer.append("isWholeWordsOnly =").append(isWholeWordsOnly).append("\n");
buffer.append("isInStringLiterals =").append(isInStringLiteralsOnly).append("\n");
buffer.append("isInComments =").append(isInCommentsOnly).append("\n");
buffer.append("searchContext =").append(searchContext).append("\n");
buffer.append("isFromCursor =").append(isFromCursor).append("\n");
buffer.append("isForward =").append(isForward).append("\n");
buffer.append("isGlobal =").append(isGlobal).append("\n");
@@ -853,25 +849,41 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
}
}
public boolean isInStringLiteralsOnly() {
return isInStringLiteralsOnly;
public enum SearchContext {
ANY, IN_STRINGS, IN_COMMENTS, EXCEPT_STRINGS, EXCEPT_COMMENTS, EXCEPT_STRINGS_AND_COMMENTS
}
public void setInStringLiteralsOnly(boolean inStringLiteralsOnly) {
boolean changed = isInStringLiteralsOnly != inStringLiteralsOnly;
isInStringLiteralsOnly = inStringLiteralsOnly;
if (changed) {
notifyObservers();
}
public boolean isInStringLiteralsOnly() {
return searchContext == SearchContext.IN_STRINGS;
}
public boolean isExceptComments() {
return searchContext == SearchContext.EXCEPT_COMMENTS;
}
public boolean isExceptStringLiterals() {
return searchContext == SearchContext.EXCEPT_STRINGS;
}
public boolean isInCommentsOnly() {
return isInCommentsOnly;
return searchContext == SearchContext.IN_COMMENTS;
}
public void setInCommentsOnly(boolean inCommentsOnly) {
boolean changed = isInCommentsOnly != inCommentsOnly;
isInCommentsOnly = inCommentsOnly;
public boolean isExceptCommentsAndStringLiterals() {
return searchContext == SearchContext.EXCEPT_STRINGS_AND_COMMENTS;
}
public @NotNull SearchContext getSearchContext() {
return searchContext;
}
public void setSearchContext(@NotNull SearchContext _searchContext) {
doSetContext(_searchContext);
}
private void doSetContext(SearchContext newSearchContext) {
boolean changed = newSearchContext != searchContext;
searchContext = newSearchContext;
if (changed) {
notifyObservers();
}
@@ -165,7 +165,7 @@ public class ArrangementMatchingRulesControl extends JBTable {
}
final List<ArrangementSectionRule> result = ContainerUtil.newArrayList();
final List<StdArrangementMatchRule> currentRules = ContainerUtil.newArrayList();
final List<StdArrangementMatchRule> buffer = ContainerUtil.newArrayList();
String currentSectionStart = null;
for (int i = 0; i < getModel().getSize(); i++) {
Object element = getModel().getElementAt(i);
@@ -174,15 +174,12 @@ public class ArrangementMatchingRulesControl extends JBTable {
mySectionRuleManager == null ? null : mySectionRuleManager.getSectionRuleData((StdArrangementMatchRule)element);
if (sectionRule != null) {
if (sectionRule.isSectionStart()) {
if (currentSectionStart != null) {
result.add(ArrangementSectionRule.create(currentSectionStart, null, currentRules));
currentRules.clear();
}
appendBufferedSectionRules(result, buffer, currentSectionStart);
currentSectionStart = sectionRule.getText();
}
else {
result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), currentRules));
currentRules.clear();
result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), buffer));
buffer.clear();
currentSectionStart = null;
}
}
@@ -190,17 +187,34 @@ public class ArrangementMatchingRulesControl extends JBTable {
result.add(ArrangementSectionRule.create((StdArrangementMatchRule)element));
}
else {
currentRules.add((StdArrangementMatchRule)element);
buffer.add((StdArrangementMatchRule)element);
}
}
}
if (currentSectionStart != null) {
result.add(ArrangementSectionRule.create(currentSectionStart, null, currentRules));
}
appendBufferedSectionRules(result, buffer, currentSectionStart);
return result;
}
private static void appendBufferedSectionRules(@NotNull List<ArrangementSectionRule> result,
@NotNull List<StdArrangementMatchRule> buffer,
@Nullable String currentSectionStart) {
if (currentSectionStart == null) {
return;
}
if (buffer.isEmpty()) {
result.add(ArrangementSectionRule.create(currentSectionStart, null));
}
else {
result.add(ArrangementSectionRule.create(currentSectionStart, null, buffer.get(0)));
for (int j = 1; j < buffer.size(); j++) {
result.add(ArrangementSectionRule.create(buffer.get(j)));
}
buffer.clear();
}
}
@Override
protected void processMouseEvent(MouseEvent e) {
int id = e.getID();
@@ -17,17 +17,24 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.formatting.*;
import com.intellij.lang.LanguageFormatting;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -57,27 +64,32 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
return false;
}
Project project = file.getProject();
Document document = editor.getDocument();
CaretModel caretModel = editor.getCaretModel();
boolean isUncommitted = PsiDocumentManager.getInstance(project).isUncommited(document);
int caretOffset = editor.getCaretModel().getOffset();
int caretOffset = caretModel.getOffset();
int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), caretOffset, " \t");
int offsetInPsi = offset + (isUncommitted ? 1 : 0);
int beforeWhitespaceOffset = CharArrayUtil.shiftBackward(document.getCharsSequence(), offset - 1, " \t") + 1;
LogicalPosition logicalPosition = caretOffset < offset ? editor.offsetToLogicalPosition(offset) : editor.getCaretModel().getLogicalPosition();
LogicalPosition logicalPosition = caretOffset < offset ? editor.offsetToLogicalPosition(offset) : caretModel.getLogicalPosition();
int lineStartOffset = document.getLineStartOffset(logicalPosition.line);
if (lineStartOffset < beforeWhitespaceOffset) {
if (caretWasAtLineStart && beforeWhitespaceOffset < offset) {
document.deleteString(beforeWhitespaceOffset, offset);
return true;
if (caretWasAtLineStart && beforeWhitespaceOffset <= offset) {
String spacing = getSpacing(file, offsetInPsi);
if (beforeWhitespaceOffset < offset || !spacing.isEmpty()) {
document.replaceString(beforeWhitespaceOffset, offset, spacing);
caretModel.moveToOffset(beforeWhitespaceOffset + spacing.length());
return true;
}
}
return false;
}
Project project = file.getProject();
CodeStyleFacade codeStyleFacade = CodeStyleFacade.getInstance(project);
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
// We should calculate indent at line containing the text after caret, cause that text might affect the result (e.g. closing brace in Java)
String indent = codeStyleFacade.getLineIndent(document, caretWasAtLineStart && psiDocumentManager.isUncommited(document)
? initialCaretOffset : lineStartOffset);
String indent = codeStyleFacade.getLineIndent(document, caretWasAtLineStart && isUncommitted ? initialCaretOffset : lineStartOffset);
if (indent == null) {
return false;
}
@@ -87,7 +99,7 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
if (logicalPosition.column == targetColumn) {
if (caretOffset < offset) {
editor.getCaretModel().moveToLogicalPosition(logicalPosition);
caretModel.moveToLogicalPosition(logicalPosition);
return true;
}
return false;
@@ -95,7 +107,7 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
if (caretWasAtLineStart || logicalPosition.column > targetColumn) {
document.replaceString(lineStartOffset, offset, indent);
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line, targetColumn));
caretModel.moveToLogicalPosition(new LogicalPosition(logicalPosition.line, targetColumn));
return true;
}
@@ -108,12 +120,13 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
int targetOffset = CharArrayUtil.shiftBackward(document.getCharsSequence(), prevLineEndOffset - 1, " \t") + 1;
if (prevLineStartOffset < targetOffset) {
document.deleteString(targetOffset, offset);
editor.getCaretModel().moveToOffset(targetOffset);
String spacing = getSpacing(file, offsetInPsi);
document.replaceString(targetOffset, offset, spacing);
caretModel.moveToOffset(targetOffset + spacing.length());
}
else {
document.replaceString(prevLineStartOffset, offset, indent);
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line - 1, targetColumn));
caretModel.moveToLogicalPosition(new LogicalPosition(logicalPosition.line - 1, targetColumn));
}
return true;
}
@@ -140,4 +153,15 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
}
return width;
}
private static String getSpacing(PsiFile file, int offset) {
FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(file);
if (builder == null) {
return "";
}
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(file.getProject());
FormattingModel model = builder.createModel(file, settings);
int spacing = FormatterEx.getInstance().getSpacingForBlockAtOffset(model, offset);
return StringUtil.repeatSymbol(' ', spacing);
}
}
@@ -670,12 +670,14 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
}
}
@NotNull
public Editor getCurrentEditor() {
return ObjectUtils.chooseNotNull(myCurrentEditor, myConsoleEditor);
return ObjectUtils.notNull(myCurrentEditor, myConsoleEditor);
}
@NotNull
public Language getLanguage() {
return myVirtualFile.getLanguage();
return ObjectUtils.assertNotNull(myVirtualFile.getLanguage());
}
public void setLanguage(@NotNull Language language) {
@@ -392,6 +392,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
if (secondaryActionsAvailable()) {
actionGroup.addAction(new ToggleInCommentsAction(this)).setAsSecondary(true);
actionGroup.addAction(new ToggleInLiteralsOnlyAction(this)).setAsSecondary(true);
actionGroup.addAction(new ToggleExceptCommentsAction(this)).setAsSecondary(true);
actionGroup.addAction(new ToggleExceptLiteralsAction(this)).setAsSecondary(true);
actionGroup.addAction(new ToggleExceptCommentsAndLiteralsAction(this)).setAsSecondary(true);
}
actionGroup.addAction(new TogglePreserveCaseAction(this));
actionGroup.addAction(new ToggleSelectionOnlyAction(this));
@@ -473,8 +476,7 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
to.setCaseSensitive(from.isCaseSensitive());
to.setWholeWordsOnly(from.isWholeWordsOnly());
to.setRegularExpressions(from.isRegularExpressions());
to.setInCommentsOnly(from.isInCommentsOnly());
to.setInStringLiteralsOnly(from.isInStringLiteralsOnly());
to.setSearchContext(from.getSearchContext());
if (from.isReplaceState()) {
to.setPreserveCase(from.isPreserveCase());
}
@@ -119,4 +119,13 @@ public abstract class FindSettings{
public abstract boolean isInCommentsOnly();
public abstract void setInCommentsOnly(boolean selected);
public abstract boolean isExceptStringLiterals();
public abstract void setExceptStringLiterals(boolean selected);
public abstract boolean isExceptComments();
public abstract void setExceptComments(boolean selected);
public abstract boolean isExceptCommentsAndLiterals();
public abstract void setExceptCommentsAndLiterals(boolean selected);
}
@@ -0,0 +1,38 @@
/*
* 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;
import com.intellij.find.FindModel;
import com.intellij.openapi.actionSystem.AnActionEvent;
public class ToggleExceptCommentsAction extends EditorHeaderToggleAction implements SecondaryHeaderAction {
private static final String TEXT = "Except C&omments";
public ToggleExceptCommentsAction(EditorSearchComponent editorSearchComponent) {
super(editorSearchComponent, TEXT);
}
@Override
public boolean isSelected(AnActionEvent e) {
return getEditorSearchComponent().getFindModel().isExceptComments();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_COMMENTS : FindModel.SearchContext.ANY);
}
}
@@ -0,0 +1,38 @@
/*
* 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;
import com.intellij.find.FindModel;
import com.intellij.openapi.actionSystem.AnActionEvent;
public class ToggleExceptCommentsAndLiteralsAction extends EditorHeaderToggleAction implements SecondaryHeaderAction {
private static final String TEXT = "Except Comments and Li&terals";
public ToggleExceptCommentsAndLiteralsAction(EditorSearchComponent editorSearchComponent) {
super(editorSearchComponent, TEXT);
}
@Override
public boolean isSelected(AnActionEvent e) {
return getEditorSearchComponent().getFindModel().isExceptCommentsAndStringLiterals();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS : FindModel.SearchContext.ANY);
}
}
@@ -0,0 +1,38 @@
/*
* 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;
import com.intellij.find.FindModel;
import com.intellij.openapi.actionSystem.AnActionEvent;
public class ToggleExceptLiteralsAction extends EditorHeaderToggleAction implements SecondaryHeaderAction {
private static final String TEXT = "Except L&iterals";
public ToggleExceptLiteralsAction(EditorSearchComponent editorSearchComponent) {
super(editorSearchComponent, TEXT);
}
@Override
public boolean isSelected(AnActionEvent e) {
return getEditorSearchComponent().getFindModel().isExceptStringLiterals();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_STRINGS : FindModel.SearchContext.ANY);
}
}
@@ -18,8 +18,6 @@ public class ToggleInCommentsAction extends EditorHeaderToggleAction implements
@Override
public void setSelected(AnActionEvent e, boolean state) {
FindModel findModel = getEditorSearchComponent().getFindModel();
findModel.setInCommentsOnly(state);
if (state) findModel.setInStringLiteralsOnly(false);
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.IN_COMMENTS : FindModel.SearchContext.ANY);
}
}
@@ -18,8 +18,6 @@ public class ToggleInLiteralsOnlyAction extends EditorHeaderToggleAction implem
@Override
public void setSelected(AnActionEvent e, boolean state) {
FindModel findModel = getEditorSearchComponent().getFindModel();
findModel.setInStringLiteralsOnly(state);
if (state) findModel.setInCommentsOnly(false);
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.IN_STRINGS : FindModel.SearchContext.ANY);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -35,7 +35,6 @@ import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.*;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -50,8 +49,6 @@ import com.intellij.ui.EditorComboBoxRenderer;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.StateRestoringCheckBox;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
@@ -60,7 +57,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
@@ -78,8 +74,7 @@ public class FindDialog extends DialogWrapper {
private StateRestoringCheckBox myCbCaseSensitive;
private StateRestoringCheckBox myCbPreserveCase;
private StateRestoringCheckBox myCbWholeWordsOnly;
private StateRestoringCheckBox myCbInCommentsOnly;
private StateRestoringCheckBox myCbInStringLiteralsOnly;
private ComboBox mySearchContext;
private StateRestoringCheckBox myCbRegularExpressions;
private JRadioButton myRbGlobal;
private JRadioButton myRbSelectedText;
@@ -476,6 +471,9 @@ public class FindDialog extends DialogWrapper {
findSettings.setWholeWordsOnly(myModel.isWholeWordsOnly());
findSettings.setInStringLiteralsOnly(myModel.isInStringLiteralsOnly());
findSettings.setInCommentsOnly(myModel.isInCommentsOnly());
findSettings.setExceptComments(myModel.isExceptComments());
findSettings.setExceptStringLiterals(myModel.isExceptStringLiterals());
findSettings.setExceptCommentsAndLiterals(myModel.isExceptCommentsAndStringLiterals());
findSettings.setRegularExpressions(myModel.isRegularExpressions());
if (!myModel.isMultipleFiles()){
@@ -603,39 +601,37 @@ public class FindDialog extends DialogWrapper {
regExPanel.setLayout(new BoxLayout(regExPanel, BoxLayout.X_AXIS));
regExPanel.add(myCbRegularExpressions);
regExPanel.add(new LinkLabel("[Help]", null, new LinkListener() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
try {
final JBPopup helpPopup = RegExHelpPopup.createRegExHelpPopup();
helpPopup.showInCenterOf(regExPanel);
}
catch (BadLocationException e) {
LOG.info(e);
}
}
}));
regExPanel.add(RegExHelpPopup.createRegExLink("[Help]", regExPanel, LOG));
findOptionsPanel.add(regExPanel);
myCbInCommentsOnly = createCheckbox(FindBundle.message("find.options.comments.only"));
myCbInStringLiteralsOnly = createCheckbox(FindBundle.message("find.options.string.literals.only"));
ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == myCbInCommentsOnly) {
if (myCbInCommentsOnly.isSelected()) myCbInStringLiteralsOnly.setSelected(false);
} else if (e.getSource() == myCbInStringLiteralsOnly) {
if (myCbInStringLiteralsOnly.isSelected()) myCbInCommentsOnly.setSelected(false);
}
}
};
myCbInCommentsOnly.addItemListener(itemListener);
myCbInStringLiteralsOnly.addItemListener(itemListener);
mySearchContext = new ComboBox(new Object[] {FindBundle.message("find.context.anywhere.scope.label", 200),
FindBundle.message("find.context.in.comments.scope.label"), FindBundle.message("find.context.in.literals.scope.label"),
FindBundle.message("find.context.except.comments.scope.label"),
FindBundle.message("find.context.except.literals.scope.label"),
FindBundle.message("find.context.except.comments.and.literals.scope.label")});
final JPanel searchContextPanel = new JPanel(new GridBagLayout());
searchContextPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
gbConstraints.gridwidth = 1;
gbConstraints.weightx = 1;
JLabel searchContextLabel = new JLabel(FindBundle.message("find.context.combo.label"));
searchContextLabel.setLabelFor(mySearchContext);
searchContextPanel.add(searchContextLabel, gbConstraints);
++gbConstraints.gridx;
searchContextPanel.add(mySearchContext, gbConstraints);
if (FindManagerImpl.ourHasSearchInCommentsAndLiterals) {
findOptionsPanel.add(myCbInCommentsOnly);
findOptionsPanel.add(myCbInStringLiteralsOnly);
findOptionsPanel.add(searchContextPanel);
}
ActionListener actionListener = new ActionListener() {
@@ -1000,9 +996,25 @@ public class FindDialog extends DialogWrapper {
}
model.setWholeWordsOnly(myCbWholeWordsOnly.isSelected());
model.setInStringLiteralsOnly(myCbInStringLiteralsOnly.isSelected());
model.setInCommentsOnly(myCbInCommentsOnly.isSelected());
String selectedSearchContextInUi = (String)mySearchContext.getSelectedItem();
FindModel.SearchContext searchContext = FindModel.SearchContext.ANY;
if (FindBundle.message("find.context.in.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.IN_STRINGS;
}
else if (FindBundle.message("find.context.in.comments.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.IN_COMMENTS;
}
else if (FindBundle.message("find.context.except.comments.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_COMMENTS;
}
else if (FindBundle.message("find.context.except.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_STRINGS;
} else if (FindBundle.message("find.context.except.comments.and.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS;
}
model.setSearchContext(searchContext);
model.setRegularExpressions(myCbRegularExpressions.isSelected());
String stringToFind = getStringToFind();
@@ -1068,8 +1080,14 @@ public class FindDialog extends DialogWrapper {
private void initByModel() {
myCbCaseSensitive.setSelected(myModel.isCaseSensitive());
myCbWholeWordsOnly.setSelected(myModel.isWholeWordsOnly());
myCbInStringLiteralsOnly.setSelected(myModel.isInStringLiteralsOnly());
myCbInCommentsOnly.setSelected(myModel.isInCommentsOnly());
String searchContext = FindBundle.message("find.context.anywhere.scope.label");
if (myModel.isInCommentsOnly()) searchContext = FindBundle.message("find.context.in.comments.scope.label");
else if (myModel.isInStringLiteralsOnly()) searchContext = FindBundle.message("find.context.in.literals.scope.label");
else if (myModel.isExceptStringLiterals()) searchContext = FindBundle.message("find.context.except.literals.scope.label");
else if (myModel.isExceptComments()) searchContext = FindBundle.message("find.context.except.literals.scope.label");
else if (myModel.isExceptCommentsAndStringLiterals()) searchContext = FindBundle.message("find.context.except.comments.and.literals.scope.label");
mySearchContext.setSelectedItem(searchContext);
myCbRegularExpressions.setSelected(myModel.isRegularExpressions());
if (myModel.isMultipleFiles()) {
@@ -64,6 +64,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.ui.LightweightHint;
import com.intellij.ui.ReplacePromptDialog;
import com.intellij.usages.ChunkExtractor;
import com.intellij.usages.UsageViewManager;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
@@ -572,8 +573,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
final TextAttributesKey[] keys = activeSyntaxHighlighter.getTokenHighlights(tokenType);
if (tokens.contains(tokenType) ||
(model.isInStringLiteralsOnly() && isHighlightedAsString(keys)) ||
(model.isInCommentsOnly() && isHighlightedAsDocComment(keys))
(model.isInStringLiteralsOnly() && ChunkExtractor.isHighlightedAsString(keys)) ||
(model.isInCommentsOnly() && ChunkExtractor.isHighlightedAsComment(keys))
) {
int start = lexer.getTokenStart();
int end = lexer.getTokenEnd();
@@ -646,32 +647,6 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
return prevFindResult;
}
private static boolean isHighlightedAsDocComment(TextAttributesKey... keys) {
for (TextAttributesKey key : keys) {
if (key == DefaultLanguageHighlighterColors.DOC_COMMENT || key == SyntaxHighlighterColors.DOC_COMMENT) {
return true;
}
final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey();
if (fallbackAttributeKey != null && isHighlightedAsDocComment(fallbackAttributeKey)) {
return true;
}
}
return false;
}
private static boolean isHighlightedAsString(TextAttributesKey... keys) {
for (TextAttributesKey key : keys) {
if (key == DefaultLanguageHighlighterColors.STRING || key == SyntaxHighlighterColors.STRING) {
return true;
}
final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey();
if (fallbackAttributeKey != null && isHighlightedAsString(fallbackAttributeKey)) {
return true;
}
}
return false;
}
private static TokenSet addTokenTypesForLanguage(FindModel model, Language lang, TokenSet tokensOfInterest) {
ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
if (definition != null) {
@@ -110,7 +110,13 @@ public class FindResultUsageInfo extends UsageInfo {
assert result.isStringFound();
if (myFindModel.isRegularExpressions() || myFindModel.isInCommentsOnly() || myFindModel.isInStringLiteralsOnly()) {
if (myFindModel.isRegularExpressions() ||
myFindModel.isInCommentsOnly() ||
myFindModel.isInStringLiteralsOnly() ||
myFindModel.isExceptStringLiterals() ||
myFindModel.isExceptCommentsAndStringLiterals() ||
myFindModel.isExceptComments()
) {
myAnchor = SmartPointerManager.getInstance(getProject()).createSmartPsiFileRangePointer(file, TextRange.from(offset, 0));
}
@@ -103,6 +103,9 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
@SuppressWarnings({"WeakerAccess"}) public boolean WHOLE_WORDS_ONLY = false;
@SuppressWarnings({"WeakerAccess"}) public boolean COMMENTS_ONLY = false;
@SuppressWarnings({"WeakerAccess"}) public boolean STRING_LITERALS_ONLY = false;
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS_AND_LITERALS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_LITERALS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_WHOLE_WORDS_ONLY = false;
@SuppressWarnings({"WeakerAccess"}) public boolean REGULAR_EXPRESSIONS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_REGULAR_EXPRESSIONS = false;
@@ -276,8 +279,18 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
model.setGlobal(isGlobal());
model.setRegularExpressions(isRegularExpressions());
model.setWholeWordsOnly(isWholeWordsOnly());
model.setInCommentsOnly(isInCommentsOnly());
model.setInStringLiteralsOnly(isInStringLiteralsOnly());
FindModel.SearchContext searchContext = isInCommentsOnly() ?
FindModel.SearchContext.IN_COMMENTS :
isInStringLiteralsOnly() ?
FindModel.SearchContext.IN_STRINGS :
isExceptComments() ?
FindModel.SearchContext.EXCEPT_COMMENTS :
isExceptStringLiterals() ?
FindModel.SearchContext.EXCEPT_STRINGS :
isExceptCommentsAndLiterals() ?
FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS :
FindModel.SearchContext.ANY;
model.setSearchContext(searchContext);
model.setWithSubdirectories(isWithSubdirectories());
model.setFileFilter(FILE_MASK);
@@ -384,4 +397,34 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
public void setCustomScope(final String SEARCH_SCOPE) {
this.SEARCH_SCOPE = SEARCH_SCOPE;
}
@Override
public boolean isExceptComments() {
return EXCEPT_COMMENTS;
}
@Override
public void setExceptCommentsAndLiterals(boolean selected) {
EXCEPT_COMMENTS_AND_LITERALS = selected;
}
@Override
public boolean isExceptCommentsAndLiterals() {
return EXCEPT_COMMENTS_AND_LITERALS;
}
@Override
public void setExceptComments(boolean selected) {
EXCEPT_COMMENTS = selected;
}
@Override
public boolean isExceptStringLiterals() {
return EXCEPT_LITERALS;
}
@Override
public void setExceptStringLiterals(boolean selected) {
EXCEPT_LITERALS = selected;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 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.
@@ -17,12 +17,17 @@ package com.intellij.find.impl;
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.popup.ComponentPopupBuilder;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.util.MinimizeButton;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
@@ -331,6 +336,22 @@ public class RegExHelpPopup extends JPanel {
add(myScrollPane, BorderLayout.CENTER);
}
@NotNull
public static LinkLabel createRegExLink(@NotNull String title, @Nullable final Component owner, @Nullable final Logger logger) {
return new LinkLabel(title, null, new LinkListener() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
try {
final JBPopup helpPopup = createRegExHelpPopup();
helpPopup.showInCenterOf(owner);
}
catch (BadLocationException e) {
if (logger != null) logger.info(e);
}
}
});
}
@Override
public Dimension getPreferredSize() {
return new Dimension(600, 300);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 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.
@@ -116,7 +116,14 @@ public abstract class FormatterEx{
TextRange affectedRange);
public abstract void setProgressTask(@NotNull FormattingProgressTask progressIndicator);
/**
* Calculates minimum spacing, allowed by formatting model (in columns) for a block starting at given offset,
* relative to its previous sibling block.
* Returns zero, if required block cannot be found at provided offset, or spacing cannot be calculated due to some other reason.
*/
public abstract int getSpacingForBlockAtOffset(FormattingModel model, int offset);
public interface IndentInfoStorage {
void saveIndentInfo(@Nullable IndentInfo info, int startOffset);
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -108,6 +109,58 @@ public class FormatterImpl extends FormatterEx
myProgressTask.set(progressIndicator);
}
@Override
public int getSpacingForBlockAtOffset(FormattingModel model, int offset) {
Couple<Block> blockWithParent = getBlockAtOffset(null, model.getRootBlock(), offset);
if (blockWithParent == null) {
return 0;
}
Block parentBlock = blockWithParent.first;
Block targetBlock = blockWithParent.second;
if (parentBlock == null || targetBlock == null) {
return 0;
}
Block prevBlock = findPreviousSibling(parentBlock, targetBlock);
if (prevBlock == null) {
return 0;
}
SpacingImpl spacing = (SpacingImpl)parentBlock.getSpacing(prevBlock, targetBlock);
if (spacing == null) {
return 0;
}
return spacing.getMinSpaces();
}
private static Couple<Block> getBlockAtOffset(Block parent, Block block, int offset) {
TextRange textRange = block.getTextRange();
int startOffset = textRange.getStartOffset();
int endOffset = textRange.getEndOffset();
if (startOffset == offset) {
return Couple.of(parent, block);
}
if (startOffset > offset || endOffset < offset || block.isLeaf()) {
return null;
}
for (Block subBlock : block.getSubBlocks()) {
Couple<Block> result = getBlockAtOffset(block, subBlock, offset);
if (result != null) {
return result;
}
}
return null;
}
private static Block findPreviousSibling(Block parent, Block block) {
Block result = null;
for (Block subBlock : parent.getSubBlocks()) {
if (subBlock == block) {
return result;
}
result = subBlock;
}
return null;
}
@Override
public void format(final FormattingModel model, final CodeStyleSettings settings,
final CommonCodeStyleSettings.IndentOptions indentOptions,
@@ -100,8 +100,7 @@ public class GeneratedParserUtilBase {
if (!goodMarker) return false;
ErrorState state = ErrorState.get(builder_);
Frame frame = state.frameStack.peekLast();
return frame == null || frame.errorReportedAt <= builder_.rawTokenIndex();
return !state.frameStack.isEmpty();
}
public static TokenSet create_token_set_(IElementType... tokenTypes_) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -33,12 +33,14 @@ import com.intellij.openapi.roots.ModuleRootModel;
import com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel;
import com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout;
import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.ex.VirtualFileManagerAdapter;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.ui.roots.ToolbarPanel;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
@@ -48,6 +50,7 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@@ -146,7 +149,9 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
myContentEntryEditorListener = new MyContentEntryEditorListener();
final JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
if (!Registry.is("ide.new.project.settings")) {
mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
}
addAdditionalSettingsToPanel(mainPanel);
@@ -159,21 +164,35 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
myEditorsPanel = new ScrollablePanel(new VerticalStackLayout());
myEditorsPanel.setBackground(BACKGROUND_COLOR);
JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel);
entriesPanel.add(new ToolbarPanel(myScrollPane, group), BorderLayout.CENTER);
JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel, Registry.is("ide.new.project.settings"));
final ToolbarPanel toolbarPanel = new ToolbarPanel(myScrollPane, group);
if (Registry.is("ide.new.project.settings")) {
toolbarPanel.setBorder(new CustomLineBorder(1,0,0,0));
}
entriesPanel.add(toolbarPanel, BorderLayout.CENTER);
final Splitter splitter = new Splitter(false);
final JBSplitter splitter = new JBSplitter(false);
if (Registry.is("ide.new.project.settings")) {
splitter.setOnePixelMode();
}
splitter.setProportion(0.6f);
splitter.setHonorComponentsMinimumSize(true);
myRootTreeEditor = createContentEntryTreeEditor(project);
splitter.setFirstComponent(myRootTreeEditor.createComponent());
final JComponent component = myRootTreeEditor.createComponent();
if (Registry.is("ide.new.project.settings")) {
component.setBorder(new CustomLineBorder(1,0,0,0));
}
splitter.setFirstComponent(component);
splitter.setSecondComponent(entriesPanel);
JPanel contentPanel = new JPanel(new GridBagLayout());
contentPanel.setBorder(BorderFactory.createEtchedBorder());
if (!Registry.is("ide.new.project.settings")) {
contentPanel.setBorder(BorderFactory.createEtchedBorder());
}
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myRootTreeEditor.getEditingActionsGroup(), true);
contentPanel.add(new JLabel("Mark as:"),
new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, new Insets(0, 5, 0, 5), 0, 0));
new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, new Insets(0, 10, 0, 10), 0, 0));
contentPanel.add(actionToolbar.getComponent(),
new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
@@ -236,7 +255,11 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
if (componentBorder != null) {
border = BorderFactory.createCompoundBorder(border, componentBorder);
}
component.setBorder(border);
if (Registry.is("ide.new.project.settings")) {
component.setBorder(new EmptyBorder(0,0,0,0));
} else {
component.setBorder(border);
}
myEditorsPanel.add(component);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -36,6 +36,7 @@ import com.intellij.ui.roots.IconActionComponent;
import com.intellij.ui.roots.ResizingWrapper;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.util.NotNullProducer;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -59,10 +60,22 @@ import java.util.Map;
*/
public abstract class ContentRootPanel extends JPanel {
private static final Color EXCLUDED_COLOR = new JBColor(new Color(0x992E00), DarculaColors.RED);
private static final Color SELECTED_HEADER_COLOR = new JBColor(new Color(0xDEF2FF), UIUtil.getPanelBackground().darker());
private static final Color SELECTED_HEADER_COLOR = new JBColor(new NotNullProducer<Color>() {
@NotNull
@Override
public Color produce() {
return UIUtil.isUnderDarcula() ? UIUtil.getPanelBackground().darker() : new Color(0xDEF2FF);
}
});
private static final Color HEADER_COLOR = new JBColor(new Color(0xF5F5F5), Gray._82);
private static final Color SELECTED_CONTENT_COLOR = new Color(0xF0F9FF);
private static final Color CONTENT_COLOR = new JBColor(Color.WHITE, UIUtil.getPanelBackground());
private static final Color CONTENT_COLOR = new JBColor(new NotNullProducer<Color>() {
@NotNull
@Override
public Color produce() {
return UIUtil.isUnderDarcula() ? UIUtil.getPanelBackground() : Gray._255;
}
});
private static final Color UNSELECTED_TEXT_COLOR = Gray._51;
protected final ActionCallback myCallback;
@@ -140,7 +153,7 @@ public abstract class ContentRootPanel extends JPanel {
headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD));
headerLabel.setOpaque(false);
if (getContentEntry().getFile() == null) {
headerLabel.setForeground(Color.RED);
headerLabel.setForeground(JBColor.RED);
}
final IconActionComponent deleteIconComponent = new IconActionComponent(AllIcons.Modules.DeleteContentRoot,
AllIcons.Modules.DeleteContentRootRollover,
@@ -1205,7 +1205,7 @@ public class SingleInspectionProfilePanel extends JPanel {
}
public JComponent getTree() {
return myTreeTable.getTree();
return myTreeTable == null ? null : myTreeTable.getTree();
}
private class MyFilterComponent extends FilterComponent {
@@ -16,6 +16,7 @@
package com.intellij.psi.impl.source.tree.injected;
import com.intellij.extapi.psi.PsiFileBase;
import com.intellij.injected.editor.*;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageUtil;
@@ -48,8 +49,10 @@ import java.util.List;
* @author cdr
*/
public class InjectedLanguageUtil {
static final Key<List<Trinity<IElementType, SmartPsiElementPointer<PsiLanguageInjectionHost>, TextRange>>> HIGHLIGHT_TOKENS = Key.create("HIGHLIGHT_TOKENS");
public static Key<Boolean> FRANKENSTEIN_INJECTION = Key.create("FRANKENSTEIN_INJECTION"); // meaning: injected file text is probably incorrect
static final Key<List<Trinity<IElementType, SmartPsiElementPointer<PsiLanguageInjectionHost>, TextRange>>> HIGHLIGHT_TOKENS =
Key.create("HIGHLIGHT_TOKENS");
public static Key<Boolean> FRANKENSTEIN_INJECTION = Key.create("FRANKENSTEIN_INJECTION");
// meaning: injected file text is probably incorrect
public static void forceInjectionOnElement(@NotNull PsiElement host) {
enumerate(host, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
@@ -113,9 +116,9 @@ public class InjectedLanguageUtil {
* @return true if enumerated successfully
*/
public static boolean enumerate(@NotNull PsiElement host,
@NotNull PsiFile containingFile,
boolean probeUp,
@NotNull PsiLanguageInjectionHost.InjectedPsiVisitor visitor) {
@NotNull PsiFile containingFile,
boolean probeUp,
@NotNull PsiLanguageInjectionHost.InjectedPsiVisitor visitor) {
//do not inject into nonphysical files except during completion
if (!containingFile.isPhysical() && containingFile.getOriginalFile() == containingFile) {
final PsiElement context = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
@@ -175,6 +178,32 @@ public class InjectedLanguageUtil {
return null;
}
/**
* Finds injected language in expression
*
* @param expression where to find
* @param classToFind class that represents language we look for
* @param <T> class that represents language we look for
* @return instance of class that represents language we look for or null of not found
*/
@Nullable
@SuppressWarnings("unchecked") // We check types dynamically (using isAssignableFrom)
public static <T extends PsiFileBase> T findInjectedFile(@NotNull final PsiElement expression,
@NotNull final Class<T> classToFind) {
final List<Pair<PsiElement, TextRange>> files =
InjectedLanguageManager.getInstance(expression.getProject()).getInjectedPsiFiles(expression);
if (files == null) {
return null;
}
for (final Pair<PsiElement, TextRange> fileInfo : files) {
final PsiElement injectedFile = fileInfo.first;
if (classToFind.isAssignableFrom(injectedFile.getClass())) {
return (T)injectedFile;
}
}
return null;
}
public static Editor getEditorForInjectedLanguageNoCommit(@Nullable Editor editor, @Nullable PsiFile file, final int offset) {
if (editor == null || file == null || editor instanceof EditorWindow) return editor;
PsiFile injectedFile = findInjectedPsiNoCommit(file, offset);
@@ -200,7 +229,9 @@ public class InjectedLanguageUtil {
}
}
}
if (!documentWindow.isValid()) return hostEditor; // since the moment we got hold of injectedFile and this moment call, document may have been dirtied
if (!documentWindow.isValid()) {
return hostEditor; // since the moment we got hold of injectedFile and this moment call, document may have been dirtied
}
return EditorWindowImpl.create(documentWindow, (EditorImpl)hostEditor, injectedFile);
}
@@ -284,7 +315,8 @@ public class InjectedLanguageUtil {
ParameterizedCachedValue<MultiHostRegistrarImpl, PsiElement> cachedValue =
CachedValuesManager.getManager(project).createParameterizedCachedValue(INJECTED_PSI_PROVIDER, false);
CachedValueProvider.Result<MultiHostRegistrarImpl> result = CachedValueProvider.Result.create(registrar, PsiModificationTracker.MODIFICATION_COUNT, registrar);
CachedValueProvider.Result<MultiHostRegistrarImpl> result =
CachedValueProvider.Result.create(registrar, PsiModificationTracker.MODIFICATION_COUNT, registrar);
((PsiParameterizedCachedValue<MultiHostRegistrarImpl, PsiElement>)cachedValue).setValue(result);
e.putUserData(INJECTED_PSI, cachedValue);
@@ -307,7 +339,9 @@ public class InjectedLanguageUtil {
// returns (injected psi, leaf element at the offset, language of the leaf element)
// since findElementAt() is expensive, we trying to reuse its result
@NotNull
private static Trinity<PsiElement,PsiElement,Language> tryOffset(@NotNull PsiFile hostFile, final int offset, @NotNull PsiDocumentManager documentManager) {
private static Trinity<PsiElement, PsiElement, Language> tryOffset(@NotNull PsiFile hostFile,
final int offset,
@NotNull PsiDocumentManager documentManager) {
FileViewProvider provider = hostFile.getViewProvider();
Language leafLanguage = null;
PsiElement leafElement = null;
@@ -319,11 +353,11 @@ public class InjectedLanguageUtil {
leafElement = element;
}
PsiElement injected = findInside(element, hostFile, offset, documentManager);
if (injected != null) return Trinity.create(injected,element, language);
if (injected != null) return Trinity.create(injected, element, language);
}
// maybe we are at the border between two psi elements, then try to find injection at the end of the left element
if (offset != 0 && (element == null || element.getTextRange().getStartOffset() == offset)) {
PsiElement leftElement = provider.findElementAt(offset-1, language);
PsiElement leftElement = provider.findElementAt(offset - 1, language);
if (leftElement != null && leftElement.getTextRange().getEndOffset() == offset) {
PsiElement injected = findInside(leftElement, hostFile, offset, documentManager);
if (injected != null) return Trinity.create(injected, element, language);
@@ -334,7 +368,10 @@ public class InjectedLanguageUtil {
return Trinity.create(null, leafElement, leafLanguage);
}
private static PsiElement findInside(@NotNull PsiElement element, @NotNull PsiFile hostFile, final int hostOffset, @NotNull final PsiDocumentManager documentManager) {
private static PsiElement findInside(@NotNull PsiElement element,
@NotNull PsiFile hostFile,
final int hostOffset,
@NotNull final PsiDocumentManager documentManager) {
final Ref<PsiElement> out = new Ref<PsiElement>();
enumerate(element, hostFile, true, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
@Override
@@ -361,10 +398,12 @@ public class InjectedLanguageUtil {
// modification of cachedInjectedDocuments must be under PsiLock only
ConcurrentList<DocumentWindow> injected = hostPsiFile.getUserData(INJECTED_DOCS_KEY);
if (injected == null) {
injected = ((UserDataHolderEx)hostPsiFile).putUserDataIfAbsent(INJECTED_DOCS_KEY, ContainerUtil.<DocumentWindow>createConcurrentList());
injected =
((UserDataHolderEx)hostPsiFile).putUserDataIfAbsent(INJECTED_DOCS_KEY, ContainerUtil.<DocumentWindow>createConcurrentList());
}
return injected;
}
public static void clearCachedInjectedFragmentsForFile(@NotNull PsiFile file) {
file.putUserData(INJECTED_DOCS_KEY, null);
}
@@ -426,10 +465,12 @@ public class InjectedLanguageUtil {
}
return containingFile;
}
@NotNull
public static Editor getTopLevelEditor(@NotNull Editor editor) {
return editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
}
public static boolean isInInjectedLanguagePrefixSuffix(@NotNull final PsiElement element) {
PsiFile injectedFile = element.getContainingFile();
if (injectedFile == null) return false;
@@ -461,13 +502,13 @@ public class InjectedLanguageUtil {
public static String getUnescapedText(PsiFile file, @Nullable final PsiElement startElement, @Nullable final PsiElement endElement) {
final InjectedLanguageManager manager = InjectedLanguageManager.getInstance(file.getProject());
if (manager.getInjectionHost(file) == null) {
return file.getText().substring(startElement == null? 0 : startElement.getTextRange().getStartOffset(),
endElement == null? file.getTextLength() : endElement.getTextRange().getStartOffset());
return file.getText().substring(startElement == null ? 0 : startElement.getTextRange().getStartOffset(),
endElement == null ? file.getTextLength() : endElement.getTextRange().getStartOffset());
}
final StringBuilder sb = new StringBuilder();
file.accept(new PsiRecursiveElementWalkingVisitor() {
Boolean myState = startElement == null? Boolean.TRUE : null;
Boolean myState = startElement == null ? Boolean.TRUE : null;
@Override
public void visitElement(PsiElement element) {
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,6 +34,7 @@ public class PackagesNotificationPanel {
myEditorPane.setBackground(UIManager.getColor("ArrowButton.background"));
myEditorPane.setContentType("text/html");
myEditorPane.setEditable(false);
myEditorPane.setVisible(false);
myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
@@ -104,11 +106,10 @@ public class PackagesNotificationPanel {
}
private void showContent(String text, final Color background) {
myEditorPane.removeAll();
String htmlText = text.startsWith("<html>") ? text : UIUtil.toHtml(text);
myEditorPane.setText(htmlText);
myEditorPane.setBackground(background);
myEditorPane.setVisible(true);
setVisibleEditorPane(true);
myErrorTitle = null;
myErrorDescription = null;
}
@@ -124,7 +125,20 @@ public class PackagesNotificationPanel {
}
public void hide() {
myEditorPane.setVisible(false);
setVisibleEditorPane(false);
}
private void setVisibleEditorPane(boolean visible) {
boolean oldVisible = myEditorPane.isVisible();
myEditorPane.setVisible(visible);
if (oldVisible != visible) {
JComponent comp = ObjectUtils.tryCast(myEditorPane.getParent(), JComponent.class);
if (comp == null) {
comp = myEditorPane;
}
comp.revalidate();
comp.repaint();
}
}
public boolean hasLinkHandler(String key) {
@@ -0,0 +1,3 @@
class Foo {
int <caret>i;
}
@@ -0,0 +1,4 @@
class Foo {
int
<caret>i;
}
@@ -0,0 +1,3 @@
class Foo {
int <caret>i;
}
@@ -0,0 +1,4 @@
class Foo {
int
<caret> i;
}
@@ -0,0 +1,3 @@
class Foo {
int <caret>i;
}
@@ -0,0 +1,4 @@
class Foo {
int
<caret>i;
}
@@ -150,6 +150,9 @@ public class BrowserUtil {
else if (SystemInfo.isMac) {
return "open";
}
else if (SystemInfo.isUnix) {
return "/usr/bin/firefox";
}
else {
return "";
}
@@ -74,10 +74,10 @@ public class BrowserLauncherAppless extends BrowserLauncher {
Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(action);
}
public static boolean canStartDefaultBrowser() {
public static boolean canUseSystemDefaultBrowserPolicy() {
return isDesktopActionSupported(Desktop.Action.BROWSE) ||
SystemInfo.isMac || SystemInfo.isWindows ||
SystemInfo.isUnix && SystemInfo.hasXdgOpen();
(SystemInfo.isUnix && SystemInfo.hasXdgOpen());
}
private static GeneralSettings getGeneralSettingsInstance() {
@@ -145,6 +145,10 @@ public class BrowserLauncherAppless extends BrowserLauncher {
}
}
browseUsingNotSystemDefaultBrowserPolicy(uri, settings, project);
}
protected void browseUsingNotSystemDefaultBrowserPolicy(@NotNull URI uri, @NotNull GeneralSettings settings, @Nullable Project project) {
browseUsingPath(uri.toString(), settings.getBrowserPath(), null, project, ArrayUtil.EMPTY_STRING_ARRAY);
}
@@ -88,6 +88,7 @@ public final class ChromeSettings extends BrowserSpecificSettings {
return cliOptions;
}
@Override
@NotNull
@Tag("environment-variables")
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
@@ -105,8 +106,9 @@ public final class ChromeSettings extends BrowserSpecificSettings {
return new ChromeSettingsConfigurable(this);
}
@Override
public ChromeSettings clone() {
final ChromeSettings clone = (ChromeSettings)super.clone();
ChromeSettings clone = (ChromeSettings)super.clone();
clone.myEnvironmentVariables = myEnvironmentVariables.clone();
return clone;
}
@@ -26,7 +26,6 @@ import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.DocumentAdapter;
import com.intellij.util.ObjectUtils;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@@ -48,7 +47,7 @@ public class FirefoxSettingsConfigurable implements Configurable {
private final FirefoxSettings mySettings;
private String myLastProfilesIniPath;
private String myDefaultProfilesIniPath;
private String myDefaultProfile;
private String defaultProfile;
public FirefoxSettingsConfigurable(FirefoxSettings settings) {
mySettings = settings;
@@ -89,11 +88,8 @@ public class FirefoxSettingsConfigurable implements Configurable {
@Nullable
private String getConfiguredProfileName() {
final String selected = (String)myProfileCombobox.getSelectedItem();
if (Comparing.equal(myDefaultProfile, selected)) {
return null;
}
return selected;
String selected = (String)myProfileCombobox.getSelectedItem();
return Comparing.equal(defaultProfile, selected) ? null : selected;
}
@Override
@@ -110,7 +106,9 @@ public class FirefoxSettingsConfigurable implements Configurable {
String path = mySettings.getProfilesIniPath();
myProfilesIniPathField.setText(path != null ? FileUtilRt.toSystemDependentName(path) : myDefaultProfilesIniPath);
updateProfilesList();
myProfileCombobox.setSelectedItem(ObjectUtils.notNull(mySettings.getProfile(), myDefaultProfile));
String profile = mySettings.getProfile();
myProfileCombobox.setSelectedItem(profile == null ? defaultProfile : profile);
}
private void updateProfilesList() {
@@ -122,7 +120,7 @@ public class FirefoxSettingsConfigurable implements Configurable {
myProfileCombobox.removeAllItems();
final List<FirefoxProfile> profiles = FirefoxUtil.computeProfiles(new File(profilesIniPath));
final FirefoxProfile defaultProfile = FirefoxUtil.getDefaultProfile(profiles);
myDefaultProfile = defaultProfile != null ? defaultProfile.getName() : null;
this.defaultProfile = defaultProfile != null ? defaultProfile.getName() : null;
for (FirefoxProfile profile : profiles) {
//noinspection unchecked
myProfileCombobox.addItem(profile.getName());
@@ -16,6 +16,7 @@
package com.intellij.openapi.diff;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -59,4 +60,12 @@ public abstract class DiffRequestFactory {
Project project,
@Nullable ActionButtonPresentation okButtonPresentation,
@Nullable ActionButtonPresentation cancelButtonPresentation);
public abstract MergeRequest create3WayDiffRequest(String leftText,
String rightText,
String originalContent,
@Nullable FileType type,
Project project,
@Nullable ActionButtonPresentation okButtonPresentation,
@Nullable ActionButtonPresentation cancelButtonPresentation);
}
@@ -240,7 +240,7 @@ class DragHelper extends MouseDragHelper {
final JBTabsPosition position = myTabs.getTabsPosition();
if (!willDragOutStart && JBEditorTabs.isAlphabeticalMode() && position != JBTabsPosition.top && position != JBTabsPosition.bottom) {
if (!willDragOutStart && myTabs.isAlphabeticalMode() && position != JBTabsPosition.top && position != JBTabsPosition.bottom) {
Point p = new Point(event.getPoint());
p = SwingUtilities.convertPoint(event.getComponent(), p, myTabs);
if (myTabs.getVisibleRect().contains(p) && myPressedOnScreenPoint.distance(new RelativePoint(event).getScreenPoint()) > 15) {
@@ -43,7 +43,7 @@ import java.util.List;
* @author pegov
*/
public class JBEditorTabs extends JBTabsImpl {
private static final String TABS_ALPHABETICAL_KEY = "tabs.alphabetical";
public static final String TABS_ALPHABETICAL_KEY = "tabs.alphabetical";
private JBEditorTabsPainter myDarkPainter = new DarculaEditorTabsPainter();
private JBEditorTabsPainter myDefaultPainter = new DefaultEditorTabsPainter();
@@ -130,7 +130,7 @@ public class JBEditorTabs extends JBTabsImpl {
return UIUtil.isUnderDarcula() ? myDarkPainter : myDefaultPainter;
}
public static boolean isAlphabeticalMode() {
public boolean isAlphabeticalMode() {
return Registry.is(TABS_ALPHABETICAL_KEY);
}
@@ -1262,6 +1262,10 @@ public class JBTabsImpl extends JComponent
return null;
}
public boolean isAlphabeticalMode() {
return false;
}
@Nullable
private TabInfo findEnabledBackward(int from, boolean cycle) {
if (from < 0) return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -147,7 +147,7 @@ public class SingleRowLayout extends TabLayout {
}
public LayoutPassInfo layoutSingleRow(List<TabInfo> visibleInfos) {
if (JBEditorTabs.isAlphabeticalMode()) {
if (myTabs.isAlphabeticalMode()) {
Collections.sort(visibleInfos, new Comparator<TabInfo>() {
@Override
public int compare(TabInfo o1, TabInfo o2) {
@@ -29,7 +29,7 @@ public abstract class HttpRequestHandler {
public static final ExtensionPointName<HttpRequestHandler> EP_NAME = ExtensionPointName.create("com.intellij.httpRequestHandler");
public boolean isSupported(@NotNull FullHttpRequest request) {
return request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.HEAD;
return request.method() == HttpMethod.GET || request.method() == HttpMethod.HEAD;
}
public abstract boolean process(@NotNull QueryStringDecoder urlDecoder, @NotNull FullHttpRequest request, @NotNull ChannelHandlerContext context)
@@ -59,7 +59,7 @@ public class XmlRpcServerImpl implements XmlRpcServer {
static final class XmlRpcRequestHandler extends HttpRequestHandler {
@Override
public boolean isSupported(@NotNull FullHttpRequest request) {
return request.getMethod() == HttpMethod.POST || request.getMethod() == HttpMethod.OPTIONS;
return request.method() == HttpMethod.POST || request.method() == HttpMethod.OPTIONS;
}
@Override
@@ -89,7 +89,7 @@ public class XmlRpcServerImpl implements XmlRpcServer {
return false;
}
if (request.getMethod() == HttpMethod.POST) {
if (request.method() == HttpMethod.POST) {
ByteBuf result;
ByteBufInputStream in = new ByteBufInputStream(request.content());
try {
@@ -116,7 +116,7 @@ public class XmlRpcServerImpl implements XmlRpcServer {
return true;
}
else if (HttpMethod.POST.name().equals(request.headers().get("Access-Control-Request-Method"))) {
LOG.assertTrue(request.getMethod() == HttpMethod.OPTIONS);
LOG.assertTrue(request.method() == HttpMethod.OPTIONS);
Responses.sendOptionsResponse("POST, OPTIONS", request, context);
return true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 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.
@@ -18,6 +18,7 @@ package com.intellij.ide.actions;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.tabs.impl.JBEditorTabs;
import javax.swing.*;
@@ -28,7 +29,7 @@ import javax.swing.*;
public class TabsAlphabeticalModeSwitcher extends ToggleAction {
@Override
public boolean isSelected(AnActionEvent e) {
return JBEditorTabs.isAlphabeticalMode();
return Registry.is(JBEditorTabs.TABS_ALPHABETICAL_KEY);
}
@Override
@@ -297,13 +297,11 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
myData.setContents(content1, content2);
Project project = myData.getProject();
FileType[] types = DiffUtil.chooseContentTypes(new DiffContent[]{content1, content2});
VirtualFile baseFile = content1.getFile();
if (baseFile == null && myDiffRequest != null) {
String path = myDiffRequest.getWindowTitle();
if (path != null) baseFile = LocalFileSystem.getInstance().findFileByPath(path);
}
myLeftSide.setHighlighterFactory(createHighlighter(types[0], baseFile, project));
myRightSide.setHighlighterFactory(createHighlighter(types[1], baseFile, project));
VirtualFile beforeFile = content1.getFile();
VirtualFile afterFile = content2.getFile();
String path = myDiffRequest == null ? null : myDiffRequest.getWindowTitle();
myLeftSide.setHighlighterFactory(createHighlighter(types[0], beforeFile, afterFile, path, project));
myRightSide.setHighlighterFactory(createHighlighter(types[1], afterFile, beforeFile, path, project));
setSplitterProportion(content1, content2);
rediff();
if (myIsRequestFocus) {
@@ -343,8 +341,16 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
}
}
// todo pay attention here
private static DiffHighlighterFactory createHighlighter(FileType contentType, VirtualFile file, Project project) {
return new DiffHighlighterFactoryImpl(contentType, file, project);
private static DiffHighlighterFactory createHighlighter(FileType contentType,
VirtualFile file,
VirtualFile otherFile,
String path,
Project project) {
VirtualFile baseFile = file;
if (baseFile == null) baseFile = otherFile;
if (baseFile == null && path != null) baseFile = LocalFileSystem.getInstance().findFileByPath(path);
return new DiffHighlighterFactoryImpl(contentType, baseFile, project);
}
void rediff() {
@@ -27,9 +27,7 @@ import com.intellij.openapi.diff.*;
import com.intellij.openapi.diff.actions.NextDiffAction;
import com.intellij.openapi.diff.actions.PreviousDiffAction;
import com.intellij.openapi.diff.actions.ToggleAutoScrollAction;
import com.intellij.openapi.diff.impl.DiffUtil;
import com.intellij.openapi.diff.impl.EditingSides;
import com.intellij.openapi.diff.impl.GenericDataProvider;
import com.intellij.openapi.diff.impl.*;
import com.intellij.openapi.diff.impl.highlighting.FragmentSide;
import com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter;
import com.intellij.openapi.diff.impl.incrementalMerge.ChangeList;
@@ -49,16 +47,20 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.util.diff.FilesTooBigForDiffException;
import com.intellij.util.containers.Convertor;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -235,6 +237,8 @@ public class MergePanel2 implements DiffViewer {
Editor base = getEditor(1);
Editor right = getEditor(2);
setupHighlighterSettings(left, base, right);
myMergeList.setMarkups(left, base, right);
EditingSides[] sides = {getFirstEditingSide(), getSecondEditingSide()};
myScrollSupport.install(sides);
@@ -271,6 +275,37 @@ public class MergePanel2 implements DiffViewer {
return myScrollSupport.isEnabled();
}
private void setupHighlighterSettings(Editor left, Editor base, Editor right) {
Editor[] editors = new Editor[]{left, base, right};
DiffContent[] contents = myData.getContents();
FileType[] types = DiffUtil.chooseContentTypes(contents);
VirtualFile fallbackFile = contents[1].getFile();
FileType fallbackType = contents[1].getContentType();
for (int i = 0; i < 3; i++) {
Editor editor = editors[i];
DiffContent content = contents[i];
EditorHighlighter highlighter =
createHighlighter(types[i], content.getFile(), fallbackFile, fallbackType, myData.getProject()).createHighlighter();
if (highlighter != null) {
((EditorEx)editor).setHighlighter(highlighter);
}
}
}
private static DiffHighlighterFactory createHighlighter(FileType contentType,
VirtualFile file,
VirtualFile otherFile,
FileType otherType,
Project project) {
if (file == null) file = otherFile;
if (contentType == null) contentType = otherType;
return new DiffHighlighterFactoryImpl(contentType, file, project);
}
public void setHighlighterSettings(@Nullable EditorColorsScheme settings) {
for (EditorPlace place : getEditorPlaces()) {
setHighlighterSettings(settings, place);
@@ -337,7 +372,20 @@ public class MergePanel2 implements DiffViewer {
data.customizeToolbar(myPanel.resetToolbar());
myPanel.registerToolbarActions();
if ( data instanceof MergeRequestImpl && myBuilder != null){
((MergeRequestImpl)data).setActions(myBuilder, this);
Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() {
@Override
public Boolean convert(DialogWrapper dialog) {
ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList);
int changes = counter.getChangeCounter();
int conflicts = counter.getConflictCounter();
if (changes == 0 && conflicts == 0) return true;
return Messages.showYesNoDialog(dialog.getRootPane(),
DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts),
DiffBundle.message("apply.partially.resolved.merge.dialog.title"),
Messages.getQuestionIcon()) == Messages.YES;
}
};
((MergeRequestImpl)data).setActions(myBuilder, this, preOkHook);
}
}
finally {
@@ -20,6 +20,7 @@ import com.intellij.openapi.diff.DiffRequestFactory;
import com.intellij.openapi.diff.MergeRequest;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -41,16 +42,29 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
cancelButtonPresentation);
}
else {
return create3WayDiffRequest(leftText, rightText, originalContent, project, okButtonPresentation, cancelButtonPresentation);
return create3WayDiffRequest(leftText, rightText, originalContent, file.getFileType(), project, okButtonPresentation, cancelButtonPresentation);
}
}
public MergeRequest create3WayDiffRequest(final String leftText,
final String rightText,
final String originalContent,
@Nullable FileType type,
final Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
if (type != null) {
return new MergeRequestImpl(leftText, originalContent, rightText, type, project, okButtonPresentation, cancelButtonPresentation);
}
return new MergeRequestImpl(leftText, originalContent, rightText, project, okButtonPresentation, cancelButtonPresentation);
}
public MergeRequest create3WayDiffRequest(final String leftText,
final String rightText,
final String originalContent,
final Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
return new MergeRequestImpl(leftText, originalContent, rightText, project, okButtonPresentation, cancelButtonPresentation);
return create3WayDiffRequest(leftText, rightText, originalContent, null, project, okButtonPresentation, cancelButtonPresentation);
}
}
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -75,6 +76,19 @@ public class MergeRequestImpl extends MergeRequest {
cancelButtonPresentation);
}
public MergeRequestImpl(String left,
String base,
String right,
FileType type,
Project project,
@Nullable final ActionButtonPresentation okButtonPresentation,
@Nullable final ActionButtonPresentation cancelButtonPresentation) {
this(new SimpleContent(left, type),
new SimpleContent(base, type),
new SimpleContent(right, type),
project, okButtonPresentation, cancelButtonPresentation);
}
private MergeRequestImpl(DiffContent left,
DiffContent base,
DiffContent right,
@@ -176,6 +190,10 @@ public class MergeRequestImpl extends MergeRequest {
}
public void setActions(final DialogBuilder builder, MergePanel2 mergePanel) {
setActions(builder, mergePanel, null);
}
public void setActions(final DialogBuilder builder, MergePanel2 mergePanel, final Convertor<DialogWrapper, Boolean> preOkHook) {
builder.removeAllActions(); // otherwise dialog will get default actions (OK, Cancel)
if (myOkButtonPresentation != null) {
@@ -187,6 +205,7 @@ public class MergeRequestImpl extends MergeRequest {
builder.setOkOperation(new Runnable() {
@Override
public void run() {
if (preOkHook != null && !preOkHook.convert(builder.getDialogWrapper())) return;
myOkButtonPresentation.run(builder.getDialogWrapper());
}
});
@@ -992,7 +992,16 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
}
public void setLineNumberAreaWidth(@NotNull TIntFunction calculator) {
final int lineNumberAreaWidth = calculator.execute(myLineNumberConvertor.execute(endLineNumber()));
int maxLineNumber = 0;
for (int i = endLineNumber(); i >= 0; i--) {
int number = myLineNumberConvertor.execute(i);
if (number >= 0) {
maxLineNumber = number;
break;
}
}
final int lineNumberAreaWidth = calculator.execute(maxLineNumber);
if (myLineNumberAreaWidth != lineNumberAreaWidth) {
myLineNumberAreaWidth = lineNumberAreaWidth;
fireResized();
@@ -227,7 +227,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
fm.doWhenFocusSettlesDown(run);
}
else {
run.run();
UIUtil.invokeAndWaitIfNeeded(run);
}
return result;
@@ -200,8 +200,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
if (cmp == myCloseRec) return true;
if (UIUtil.isDescendingFrom(cmp, myComp)) return true;
if (myComp == null || !myComp.isShowing()) return false;
Rectangle rectangleOnScreen = new Rectangle(myComp.getLocationOnScreen(), myComp.getSize());
return rectangleOnScreen.contains(target.getScreenPoint());
return myComp.contains(target.getScreenPoint().x, target.getScreenPoint().y);
}
public boolean isMovingForward(RelativePoint target) {
@@ -40,6 +40,11 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, @NotNull Disposable parent) {
myTabs = new JBEditorTabs(project, ActionManager.getInstance(), project == null ? null : IdeFocusManager.getInstance(project), parent) {
@Override
public boolean isAlphabeticalMode() {
return false;
}
@Override
protected void doPaintBackground(Graphics2D g2d, Rectangle clip) {
super.doPaintBackground(g2d, clip);
@@ -60,7 +65,7 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
maxOffset++;
g2d.setPaint(UIUtil.getPanelBackground());
g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.setPaint(new JBColor(Gray._181, Gray._158));
g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground()));
g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT, clip.x + clip.width, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.setPaint(UIUtil.getPanelBackground());
g2d.drawLine(clip.x, clip.y + maxLength, clip.width, clip.y + maxLength);
@@ -170,7 +170,7 @@ public class BuiltInServer implements Disposable {
@Override
protected boolean process(ChannelHandlerContext context, FullHttpRequest request, QueryStringDecoder urlDecoder) throws IOException {
return (request.getMethod() == HttpMethod.POST || request.getMethod() == HttpMethod.OPTIONS) &&
return (request.method() == HttpMethod.POST || request.method() == HttpMethod.OPTIONS) &&
XmlRpcServer.SERVICE.getInstance().process(urlDecoder.path(), request, context, handlers);
}
}
@@ -67,6 +67,8 @@ merge.partial.diff.action.name.0.1=Compare left and middle panel contents
merge.partial.diff.action.name.1.2=Compare middle and right panel contents
merge.dialog.exit.without.applying.changes.confirmation.message=Are you sure you want to exit without applying changes?
cancel.visual.merge.dialog.title=Cancel Visual Merge
merge.dialog.apply.partially.resolved.changes.confirmation.message=There are {0, choice, 0#|1#one change|2#{0, number} changes}{0, choice, 0#|1#'{1, choice, 0#|1# and }'}{1, choice, 0#|1#one conflict|2#{1, number} conflicts} left unprocessed.\nAre you sure you want to save changes and finish merging?
apply.partially.resolved.merge.dialog.title=Apply Changes
merge.all.changes.have.processed.save.and.finish.confirmation.text=All changes have been processed.\nWould you like to save changes and finish merging?
all.changes.processed.dialog.title=All Changes Processed
merge.save.and.finish.button=Save and &Finish
@@ -69,6 +69,14 @@ find.text.to.find.label=Text to &find:
find.replace.with.label=Replace &with:
find.filter.file.name.group=File name filter
find.filter.file.mask.checkbox=File m&ask(s)
find.context.combo.label=Conte&xt:
find.context.anywhere.scope.label=anywhere
find.context.in.comments.scope.label=in comments
find.context.in.literals.scope.label=in string literals
find.context.except.literals.scope.label=except string literals
find.context.except.comments.scope.label=except comments
find.context.except.comments.and.literals.scope.label=except comments and string literals
find.directory.not.found.error=Directory {0} is not found
find.invalid.regular.expression.error=Bad pattern \"{0}\": {1}
find.empty.match.regular.expression.error=Regular expression matches empty string
@@ -202,42 +202,22 @@ public class ReformatFilesWithFiltersTest extends LightPlatformTestCase {
TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory);
fileTree.createDirectoryAndMakeItCurrent("src");
PsiFile java2 = fileTree.addTestFile("Test2.java", "empty content");
PsiFile java2 = fileTree.addTestFile("Test2.tj", "empty content");
PsiFile php2 = fileTree.addTestFile("Pair2.php", "empty content");
PsiFile js2 = fileTree.addTestFile("Pair2.js", "empty content");
PsiDirectory test = fileTree.createDirectoryAndMakeItCurrent("test");
PsiFile testJava1 = fileTree.addTestFile("testJava1.java", "empty content");
PsiFile testJava1 = fileTree.addTestFile("testJava1.tj", "empty content");
PsiFile testPhp1 = fileTree.addTestFile("testPhp1.php", "empty content");
PsiFile testJs1 = fileTree.addTestFile("testJs1.js", "empty content");
GlobalSearchScope testScope = directoryScope(test, true);
Logger logger = Logger.getInstance(getClass());
logFiles(logger, "Previously formatted files: ", myMockCodeStyleManager.getFormattedFiles());
reformatWithRearrange(myWorkingDirectory, testScope);
logFiles(logger, "Currently formatted files: ", myMockCodeStyleManager.getFormattedFiles());
logFiles(logger, "Should be formatted", ContainerUtil.newArrayList(testJava1, testPhp1, testJs1));
assertWasFormatted(testJava1, testPhp1, testJs1);
assertWasNotFormatted(java2, php2, js2);
reformatAndOptimize(myWorkingDirectory, testScope);
assertWasFormatted(testJava1, testPhp1, testJs1);
assertWasNotFormatted(java2, php2, js2);
}
private void logFiles(Logger log, String message, Collection<PsiFile> files) {
StringBuilder builder;
builder = new StringBuilder();
builder.append(message).append('\n');
for (PsiFile file : files) {
builder.append(file).append('\n');
}
log.info(builder.toString());
}
public void assertWasFormatted(PsiFile... files) {
final Set<PsiFile> formattedFiles = myMockCodeStyleManager.getFormattedFiles();
for (PsiFile file : files) {
@@ -522,10 +522,8 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi
private boolean isUnderRoots(@NotNull String url) {
for (VirtualFilePointerContainer container : myRoots.values()) {
for (String rootUrl : container.getUrls()) {
if (VfsUtilCore.isEqualOrAncestor(rootUrl, url)) {
return true;
}
if (VfsUtilCore.isUnder(url, Arrays.asList(container.getUrls()))) {
return true;
}
}
return false;
@@ -272,12 +272,8 @@ public class PatternCompiler {
element.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
super.visitElement(element);
if (!(element instanceof PsiErrorElement)) {
return;
}
public void visitErrorElement(PsiErrorElement element) {
super.visitErrorElement(element);
final int startOffset = element.getTextRange().getStartOffset();
@@ -22,7 +22,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
@@ -36,8 +35,6 @@ import com.intellij.structuralsearch.plugin.replace.ReplaceOptions;
import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration;
import com.intellij.ui.ComboboxWithBrowseButton;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -46,7 +43,6 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.BadLocationException;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -117,7 +113,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
withinCombo.getComboBox().setEditable(true);
withinCombo.getButton().addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
final SelectTemplateDialog dialog = new SelectTemplateDialog(project, false, false);
dialog.show();
if (dialog.getExitCode() == OK_EXIT_CODE) {
@@ -191,7 +187,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
new ListSelectionListener() {
boolean rollingBackSelection;
public void valueChanged(ListSelectionEvent e) {
public void valueChanged(@NotNull ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
if (rollingBackSelection) {
rollingBackSelection=false;
@@ -212,7 +208,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
parameterList.setCellRenderer(
new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@NotNull JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String name = ((Variable)value).getName();
if (Configuration.CONTEXT_VAR_NAME.equals(name)) name = SSRBundle.message("complete.match.variable.name");
if (isReplacementVariable(name)) {
@@ -226,7 +222,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
maxoccursUnlimited.addChangeListener(new MyChangeListener(maxoccurs, true));
customScriptCode.getButton().addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
final EditScriptDialog dialog = new EditScriptDialog(project, customScriptCode.getChildComponent().getText());
dialog.show();
if (dialog.getExitCode() == OK_EXIT_CODE) {
@@ -505,18 +501,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
formalArgType = createRegexComponent();
customScriptCode = new ComponentWithBrowseButton<EditorTextField>(createScriptComponent(), null);
myRegExHelpLabel = new LinkLabel(SSRBundle.message("regular.expression.help.label"), null, new LinkListener() {
public void linkSelected(LinkLabel aSource, Object aLinkData) {
try {
final JBPopup helpPopup = RegExHelpPopup.createRegExHelpPopup();
helpPopup.showInCenterOf(mainForm);
}
catch (BadLocationException e) {
LOG.info(e);
}
}
});
myRegExHelpLabel = RegExHelpPopup.createRegExLink(SSRBundle.message("regular.expression.help.label"), regexp, LOG);
myRegExHelpLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
}
@@ -559,7 +544,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
inverted = _inverted;
}
public void stateChanged(ChangeEvent e) {
public void stateChanged(@NotNull ChangeEvent e) {
final JCheckBox jCheckBox = (JCheckBox)e.getSource();
component.setEnabled(inverted ^ jCheckBox.isSelected());
}
@@ -1,6 +1,6 @@
package com.intellij.structuralsearch.plugin.ui;
import com.intellij.codeInsight.hint.TooltipGroup;
import com.intellij.codeInsight.hint.TooltipController;
import com.intellij.codeInsight.template.impl.TemplateImplUtil;
import com.intellij.codeInsight.template.impl.Variable;
import com.intellij.openapi.editor.Document;
@@ -11,7 +11,6 @@ import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Created by IntelliJ IDEA.
@@ -21,7 +20,6 @@ import java.util.Iterator;
* To change this template use File | Settings | File Templates.
*/
public class SubstitutionShortInfoHandler implements DocumentListener, EditorMouseMotionListener, CaretListener {
private static final TooltipGroup SS_INFO_TOOLTIP_GROUP = new TooltipGroup("SS_INFO_TOOLTIP_GROUP", 0);
private long modificationTimeStamp;
private final ArrayList<Variable> variables = new ArrayList<Variable>();
@@ -63,9 +61,7 @@ public class SubstitutionShortInfoHandler implements DocumentListener, EditorMou
String varname = elements.subSequence(start + 1, end).toString();
Variable foundVar = null;
for(Iterator<Variable> i=variables.iterator();i.hasNext();) {
final Variable var = i.next();
for (final Variable var : variables) {
if (var.getName().equals(varname)) {
foundVar = var;
break;
@@ -79,7 +75,10 @@ public class SubstitutionShortInfoHandler implements DocumentListener, EditorMou
}
if (text.length() > 0) {
UIUtil.showTooltip(editor, start, end, text, SS_INFO_TOOLTIP_GROUP);
UIUtil.showTooltip(editor, start, end + 1, text);
}
else {
TooltipController.getInstance().cancelTooltips();
}
}
@@ -26,6 +26,7 @@ import com.intellij.structuralsearch.plugin.StructuralReplaceAction;
import com.intellij.structuralsearch.plugin.StructuralSearchAction;
import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration;
import com.intellij.structuralsearch.plugin.util.SmartPsiPointer;
import com.intellij.ui.HintHint;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -41,6 +42,7 @@ import java.awt.*;
public class UIUtil {
static Key<SubstitutionShortInfoHandler> LISTENER_KEY = Key.create("sslistener.key");
private static final String MODIFY_EDITOR_CONTENT = SSRBundle.message("modify.editor.content.command.name");
private static final TooltipGroup SS_INFO_TOOLTIP_GROUP = new TooltipGroup("SS_INFO_TOOLTIP_GROUP", 0);
@NonNls private static final String SS_GROUP = "structuralsearchgroup";
@NotNull
@@ -212,22 +214,27 @@ public class UIUtil {
}
}
static void showTooltip(@NotNull Editor editor, final int start, int end, @NotNull String text, @NotNull TooltipGroup group) {
Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
Point top = editor.logicalPositionToXY(editor.offsetToLogicalPosition(start));
static void showTooltip(@NotNull Editor editor, final int start, int end, @NotNull String text) {
final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
final Point left = editor.logicalPositionToXY(editor.offsetToLogicalPosition(start));
final int documentLength = editor.getDocument().getTextLength();
if (end >= documentLength) end = documentLength;
Point bottom = editor.logicalPositionToXY(editor.offsetToLogicalPosition(end));
final Point right = editor.logicalPositionToXY(editor.offsetToLogicalPosition(end));
Point bestPoint = new Point(top.x, bottom.y + editor.getLineHeight());
final Point bestPoint = new Point(left.x + (right.x - left.x) / 2, right.y + editor.getLineHeight() / 2);
if (!visibleArea.contains(bestPoint)) {
int defaultOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(new Point(0, 0)));
bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
if (visibleArea.x > bestPoint.x) {
bestPoint.x = visibleArea.x;
}
else if (visibleArea.x + visibleArea.width < bestPoint.x) {
bestPoint.x = visibleArea.x + visibleArea.width - 5;
}
Point p = SwingUtilities.convertPoint(editor.getContentComponent(), bestPoint, editor.getComponent().getRootPane().getLayeredPane());
TooltipController.getInstance().showTooltip(editor, p, text, false, group);
final Point p = SwingUtilities.convertPoint(editor.getContentComponent(), bestPoint,
editor.getComponent().getRootPane().getLayeredPane());
final HintHint hint = new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true)
.setCalloutShift(editor.getLineHeight() / 2 - 1);
TooltipController.getInstance().showTooltip(editor, p, text, visibleArea.width, false, SS_INFO_TOOLTIP_GROUP, hint);
}
public static void updateHighlighter(Editor editor, StructuralSearchProfile profile) {
@@ -16,6 +16,7 @@ import com.intellij.util.ArrayUtil;
import junit.framework.TestSuite;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -80,6 +81,10 @@ public abstract class FileSetTestCase extends TestSuite {
}
}
protected String loadFile(File testFile) throws IOException {
return FileUtil.loadFile(testFile);
}
protected String getDelimiter() {
return "---";
}
@@ -116,7 +121,7 @@ public abstract class FileSetTestCase extends TestSuite {
@Override
protected void runTest() throws Throwable {
String content = FileUtil.loadFile(myTestFile);
String content = loadFile(myTestFile);
assertNotNull(content);
List<String> input = new ArrayList<String>();
@@ -270,6 +270,11 @@ public class MockChangeListManager extends ChangeListManagerEx {
throw new UnsupportedOperationException();
}
@Override
public void addDirectoryToIgnoreImplicitly(@NotNull String path) {
throw new UnsupportedOperationException();
}
@Override
public void setFilesToIgnore(IgnoredFileBean... ignoredFiles) {
throw new UnsupportedOperationException();
@@ -19,9 +19,7 @@ import com.intellij.injected.editor.DocumentWindow;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
@@ -39,11 +37,13 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.reference.SoftReference;
import com.intellij.usageView.UsageTreeColors;
import com.intellij.usageView.UsageTreeColorsScheme;
import com.intellij.usages.impl.rules.UsageType;
import com.intellij.util.Processor;
import com.intellij.util.containers.FactoryMap;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.text.StringFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.lang.ref.WeakReference;
@@ -234,7 +234,7 @@ public class ChunkExtractor {
@NotNull final CharSequence chars,
int hiStart,
final int hiEnd,
@NotNull TextAttributesKey[] tokenHighlights,
@NotNull final TextAttributesKey[] tokenHighlights,
final boolean selectUsageWithBold,
@NotNull final List<TextChunk> result) {
final TextAttributes originalAttrs = convertAttributes(tokenHighlights);
@@ -249,8 +249,12 @@ public class ChunkExtractor {
int usageStart = segment.getStartOffset();
int usageEnd = segment.getEndOffset();
if (rangeIntersect(lastOffset[0], hiEnd, usageStart, usageEnd)) {
addChunk(chars, lastOffset[0], Math.max(lastOffset[0], usageStart), originalAttrs, false, result);
addChunk(chars, Math.max(lastOffset[0], usageStart), Math.min(hiEnd, usageEnd), originalAttrs, selectUsageWithBold, result);
addChunk(chars, lastOffset[0], Math.max(lastOffset[0], usageStart), originalAttrs, false, null, result);
UsageType usageType = isHighlightedAsString(tokenHighlights)
? UsageType.LITERAL_USAGE
: isHighlightedAsComment(tokenHighlights) ? UsageType.COMMENT_USAGE : null;
addChunk(chars, Math.max(lastOffset[0], usageStart), Math.min(hiEnd, usageEnd), originalAttrs, selectUsageWithBold, usageType, result);
lastOffset[0] = usageEnd;
if (usageEnd > hiEnd) {
return false;
@@ -260,22 +264,55 @@ public class ChunkExtractor {
}
});
if (lastOffset[0] < hiEnd) {
addChunk(chars, lastOffset[0], hiEnd, originalAttrs, false, result);
addChunk(chars, lastOffset[0], hiEnd, originalAttrs, false, null, result);
}
}
public static boolean isHighlightedAsComment(TextAttributesKey... keys) {
for (TextAttributesKey key : keys) {
if (key == DefaultLanguageHighlighterColors.DOC_COMMENT ||
key == SyntaxHighlighterColors.DOC_COMMENT ||
key == DefaultLanguageHighlighterColors.LINE_COMMENT ||
key == SyntaxHighlighterColors.LINE_COMMENT ||
key == DefaultLanguageHighlighterColors.BLOCK_COMMENT ||
key == SyntaxHighlighterColors.JAVA_BLOCK_COMMENT
) {
return true;
}
final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey();
if (fallbackAttributeKey != null && isHighlightedAsComment(fallbackAttributeKey)) {
return true;
}
}
return false;
}
public static boolean isHighlightedAsString(TextAttributesKey... keys) {
for (TextAttributesKey key : keys) {
if (key == DefaultLanguageHighlighterColors.STRING || key == SyntaxHighlighterColors.STRING) {
return true;
}
final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey();
if (fallbackAttributeKey != null && isHighlightedAsString(fallbackAttributeKey)) {
return true;
}
}
return false;
}
private static void addChunk(@NotNull CharSequence chars,
int start,
int end,
@NotNull TextAttributes originalAttrs,
boolean bold,
@Nullable UsageType usageType,
@NotNull List<TextChunk> result) {
if (start >= end) return;
TextAttributes attrs = bold
? TextAttributes.merge(originalAttrs, new TextAttributes(null, null, null, null, Font.BOLD))
: originalAttrs;
result.add(new TextChunk(attrs, StringFactory.createShared(CharArrayUtil.fromSequence(chars, start, end))));
result.add(new TextChunk(attrs, StringFactory.createShared(CharArrayUtil.fromSequence(chars, start, end)), usageType));
}
private static boolean rangeIntersect(int s1, int e1, int s2, int e2) {
@@ -18,17 +18,25 @@ package com.intellij.usages;
import com.intellij.openapi.editor.markup.AttributesFlyweight;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.usages.impl.rules.UsageType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TextChunk {
public static final TextChunk[] EMPTY_ARRAY = new TextChunk[0];
private final AttributesFlyweight myAttributes;
private final String myText;
private final UsageType myType;
public TextChunk(@NotNull TextAttributes attributes, @NotNull String text) {
this(attributes, text, null);
}
public TextChunk(@NotNull TextAttributes attributes, @NotNull String text, @Nullable UsageType type) {
myAttributes = attributes.getFlyweight();
myText = text;
myType = type;
}
@NotNull
@@ -45,6 +53,10 @@ public class TextChunk {
return getText();
}
public @Nullable UsageType getType() {
return myType;
}
@NotNull
public SimpleTextAttributes getSimpleAttributesIgnoreBackground() {
SimpleTextAttributes simples = SimpleTextAttributes.fromTextAttributes(getAttributes());
@@ -38,6 +38,7 @@ import com.intellij.reference.SoftReference;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.impl.rules.UsageType;
import com.intellij.usages.rules.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
@@ -493,4 +494,15 @@ public class UsageInfo2UsageAdapter implements UsageInModule,
public String getTooltipText() {
return myUsageInfo.getTooltipText();
}
public @Nullable UsageType getUsageType() {
TextChunk[] chunks = getText();
for(TextChunk chunk:chunks) {
UsageType type = chunk.getType();
if (type != null) {
return type;
}
}
return null;
}
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.usages.*;
import com.intellij.usages.rules.PsiElementUsage;
@@ -42,7 +43,13 @@ public class UsageTypeGroupingRule implements UsageGroupingRuleEx {
if (usage instanceof PsiElementUsage) {
PsiElementUsage elementUsage = (PsiElementUsage)usage;
UsageType usageType = getUsageType(elementUsage.getElement(), targets);
PsiElement element = elementUsage.getElement();
UsageType usageType = getUsageType(element, targets);
if (usageType == null && element instanceof PsiFile && elementUsage instanceof UsageInfo2UsageAdapter) {
usageType = ((UsageInfo2UsageAdapter)elementUsage).getUsageType();
}
if (usageType != null) return new UsageTypeGroup(usageType);
if (usage instanceof ReadWriteAccessUsage) {
@@ -74,6 +74,7 @@ public class AllIcons {
public static final Icon Forward = IconLoader.getIcon("/actions/forward.png"); // 16x16
public static final Icon GC = IconLoader.getIcon("/actions/gc.png"); // 16x16
public static final Icon Get = IconLoader.getIcon("/actions/get.png"); // 16x16
public static final Icon GroupByFile = IconLoader.getIcon("/actions/GroupByFile.png"); // 16x16
public static final Icon GroupByMethod = IconLoader.getIcon("/actions/groupByMethod.png"); // 16x16
public static final Icon GroupByModule = IconLoader.getIcon("/actions/GroupByModule.png"); // 16x16
public static final Icon GroupByModuleGroup = IconLoader.getIcon("/actions/GroupByModuleGroup.png"); // 16x16
@@ -134,6 +134,7 @@ public abstract class ChangeListManager implements ChangeListModification {
public abstract List<CommitExecutor> getRegisteredExecutors();
public abstract void addFilesToIgnore(final IgnoredFileBean... ignoredFiles);
public abstract void addDirectoryToIgnoreImplicitly(@NotNull String path);
public abstract void setFilesToIgnore(final IgnoredFileBean... ignoredFiles);
public abstract IgnoredFileBean[] getFilesToIgnore();
public abstract boolean isIgnoredFile(@NotNull VirtualFile file);
@@ -23,15 +23,20 @@ import com.intellij.openapi.application.RuntimeInterruptedException;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.impl.DirectoryIndexExcludePolicy;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.conflicts.ChangelistConflictTracker;
@@ -43,6 +48,7 @@ import com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotifications;
import com.intellij.util.*;
@@ -71,6 +77,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class ChangeListManagerImpl extends ChangeListManagerEx implements ProjectComponent, ChangeListOwner, JDOMExternalizable,
RoamingTypeDisabled {
public static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.ChangeListManagerImpl");
private static final String EXCLUDED_CONVERTED_TO_IGNORED_OPTION = "EXCLUDED_CONVERTED_TO_IGNORED";
private final Project myProject;
private final VcsConfiguration myConfig;
@@ -102,6 +109,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
private final List<CommitExecutor> myExecutors = new ArrayList<CommitExecutor>();
private final IgnoredFilesComponent myIgnoredIdeaLevel;
private boolean myExcludedConvertedToIgnored;
private ProgressIndicator myUpdateChangesProgressIndicator;
public static final Topic<LocalChangeListsLoadedListener> LISTS_LOADED = new Topic<LocalChangeListsLoadedListener>(
@@ -301,11 +309,29 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
myIgnoredIdeaLevel.add(IgnoredBeanFactory.ignoreFile(Project.DIRECTORY_STORE_FOLDER + "/workspace.xml", myProject));
}
}
if (!Registry.is("ide.hide.excluded.files") && !myExcludedConvertedToIgnored) {
convertExcludedToIgnored();
myExcludedConvertedToIgnored = true;
}
}
}
});
}
void convertExcludedToIgnored() {
for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.EP_NAME.getExtensions(myProject)) {
for (VirtualFile file : policy.getExcludeRootsForProject()) {
addDirectoryToIgnoreImplicitly(file.getPath());
}
}
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
for (String url : ModuleRootManager.getInstance(module).getExcludeRootUrls()) {
addDirectoryToIgnoreImplicitly(VfsUtilCore.urlToPath(url));
}
}
}
public void projectClosed() {
ProjectLevelVcsManager.getInstance(myProject).removeVcsListener(myVcsListener);
@@ -1272,6 +1298,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
setDefaultChangeList(myWorker.getListsCopy().get(0));
}
}
myExcludedConvertedToIgnored = Boolean.parseBoolean(JDOMExternalizerUtil.readField(element, EXCLUDED_CONVERTED_TO_IGNORED_OPTION));
myConflictTracker.loadState(element);
}
}
@@ -1285,6 +1312,9 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
worker = myWorker.copy();
}
new ChangeListManagerSerialization(ignoredFilesComponent, worker).writeExternal(element);
if (myExcludedConvertedToIgnored) {
JDOMExternalizerUtil.writeField(element, EXCLUDED_CONVERTED_TO_IGNORED_OPTION, String.valueOf(true));
}
myConflictTracker.saveState(element);
}
}
@@ -1352,6 +1382,15 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
scheduleUnversionedUpdate();
}
@Override
public void addDirectoryToIgnoreImplicitly(@NotNull String path) {
myIgnoredIdeaLevel.addIgnoredDirectoryImplicitly(path, myProject);
}
public IgnoredFilesComponent getIgnoredFilesComponent() {
return myIgnoredIdeaLevel;
}
private void scheduleUnversionedUpdate() {
final MyDirtyFilesScheduler scheduler = new MyDirtyFilesScheduler(myProject);
@@ -25,10 +25,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;
class ChangeListManagerSerialization {
@NonNls static final String ATT_ID = "id";
@@ -45,6 +42,8 @@ class ChangeListManagerSerialization {
@NonNls static final String NODE_LIST = "list";
@NonNls static final String NODE_IGNORED = "ignored";
@NonNls static final String NODE_CHANGE = "change";
@NonNls static final String MANUALLY_REMOVED_FROM_IGNORED = "manually-removed-from-ignored";
@NonNls static final String DIRECTORY_TAG = "directory";
private final IgnoredFilesComponent myIgnoredIdeaLevel;
private final ChangeListWorker myWorker;
@@ -64,6 +63,14 @@ class ChangeListManagerSerialization {
for (Element ignoredNode : ignoredNodes) {
readFileToIgnore(ignoredNode);
}
Element manuallyRemovedFromIgnoredTag = element.getChild(MANUALLY_REMOVED_FROM_IGNORED);
Set<String> manuallyRemovedFromIgnoredPaths = new HashSet<String>();
if (manuallyRemovedFromIgnoredTag != null) {
for (Element tag : manuallyRemovedFromIgnoredTag.getChildren(DIRECTORY_TAG)) {
manuallyRemovedFromIgnoredPaths.add(tag.getAttributeValue(ATT_PATH));
}
}
myIgnoredIdeaLevel.setDirectoriesManuallyRemovedFromIgnored(manuallyRemovedFromIgnoredPaths);
}
private void readChangeList(final Element listNode) {
@@ -146,6 +153,14 @@ class ChangeListManagerSerialization {
fileNode.setAttribute("mask", mask);
}
}
Set<String> manuallyRemovedFromIgnored = myIgnoredIdeaLevel.getDirectoriesManuallyRemovedFromIgnored();
if (!manuallyRemovedFromIgnored.isEmpty()) {
Element list = new Element(MANUALLY_REMOVED_FROM_IGNORED);
for (String path : manuallyRemovedFromIgnored) {
list.addContent(new Element(DIRECTORY_TAG).setAttribute(ATT_PATH, path));
}
element.addContent(list);
}
}
private static class ChangeComparator implements Comparator<Change> {
@@ -16,7 +16,10 @@
package com.intellij.openapi.vcs.changes;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.BeforeAfter;
import java.util.List;
@@ -30,13 +33,41 @@ public class FragmentedContent {
private final Document myBefore;
private final Document myAfter;
private final List<BeforeAfter<TextRange>> myRanges;
private boolean myOneSide;
private boolean myIsAddition;
public FragmentedContent(Document before, Document after, List<BeforeAfter<TextRange>> ranges) {
private final boolean myOneSide;
private final boolean myIsAddition;
private final VirtualFile myFileBefore;
private final VirtualFile myFileAfter;
private final FileType myFileTypeBefore;
private final FileType myFileTypeAfter;
public FragmentedContent(Document before, Document after, List<BeforeAfter<TextRange>> ranges, Change change) {
myBefore = before;
myAfter = after;
myRanges = ranges;
final FileStatus fs = change.getFileStatus();
myIsAddition = FileStatus.ADDED.equals(fs);
myOneSide = FileStatus.ADDED.equals(fs) || FileStatus.DELETED.equals(fs);
if (change.getBeforeRevision() != null) {
myFileBefore = change.getBeforeRevision().getFile().getVirtualFile();
myFileTypeBefore = change.getBeforeRevision().getFile().getFileType();
}
else {
myFileBefore = null;
myFileTypeBefore = null;
}
if (change.getAfterRevision() != null) {
myFileAfter = change.getAfterRevision().getFile().getVirtualFile();
myFileTypeAfter = change.getAfterRevision().getFile().getFileType();
}
else {
myFileAfter = null;
myFileTypeAfter = null;
}
}
public Document getBefore() {
@@ -50,7 +81,7 @@ public class FragmentedContent {
public List<BeforeAfter<TextRange>> getRanges() {
return myRanges;
}
public int getSize() {
return myRanges.size();
}
@@ -59,15 +90,23 @@ public class FragmentedContent {
return myOneSide;
}
public void setOneSide(boolean oneSide) {
myOneSide = oneSide;
}
public boolean isAddition() {
return myIsAddition;
}
public void setIsAddition(boolean isAddition) {
myIsAddition = isAddition;
public VirtualFile getFileBefore() {
return myFileBefore;
}
public VirtualFile getFileAfter() {
return myFileAfter;
}
public FileType getFileTypeBefore() {
return myFileTypeBefore;
}
public FileType getFileTypeAfter() {
return myFileTypeAfter;
}
}
@@ -81,10 +81,7 @@ public class FragmentedDiffRequestFromChange {
}
List<BeforeAfter<TextRange>> ranges = calculator.getRanges();
if (ranges == null || ranges.isEmpty()) return null;
FragmentedContent fragmentedContent = new FragmentedContent(calculator.getOldDocument(), calculator.getDocument(), ranges);
final FileStatus fs = change.getFileStatus();
fragmentedContent.setIsAddition(FileStatus.ADDED.equals(fs));
fragmentedContent.setOneSide(FileStatus.ADDED.equals(fs) || FileStatus.DELETED.equals(fs));
FragmentedContent fragmentedContent = new FragmentedContent(calculator.getOldDocument(), calculator.getDocument(), ranges, change);
VirtualFile file = filePath.getVirtualFile();
if (file == null) {
filePath.hardRefresh();
@@ -16,6 +16,7 @@
package com.intellij.openapi.vcs.changes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
@@ -27,6 +28,7 @@ import java.util.*;
public class IgnoredFilesComponent {
private final Set<IgnoredFileBean> myFilesToIgnore;
private final Map<String, IgnoredFileBean> myFilesMap;
private final Set<String> myDirectoriesManuallyRemovedFromIgnored;
public IgnoredFilesComponent(final Project project, final boolean registerListener) {
myFilesToIgnore = new LinkedHashSet<IgnoredFileBean>();
@@ -40,11 +42,13 @@ public class IgnoredFilesComponent {
}
});
}
myDirectoriesManuallyRemovedFromIgnored = new HashSet<String>();
}
public IgnoredFilesComponent(final IgnoredFilesComponent other) {
myFilesToIgnore = new LinkedHashSet<IgnoredFileBean>(other.myFilesToIgnore);
myFilesMap = new HashMap<String, IgnoredFileBean>(other.myFilesMap);
myDirectoriesManuallyRemovedFromIgnored = new HashSet<String>(other.myDirectoriesManuallyRemovedFromIgnored);
}
public void add(final IgnoredFileBean... filesToIgnore) {
@@ -54,6 +58,37 @@ public class IgnoredFilesComponent {
}
}
public Set<String> getDirectoriesManuallyRemovedFromIgnored() {
return Collections.unmodifiableSet(myDirectoriesManuallyRemovedFromIgnored);
}
public void setDirectoriesManuallyRemovedFromIgnored(Set<String> directories) {
myDirectoriesManuallyRemovedFromIgnored.clear();
myDirectoriesManuallyRemovedFromIgnored.addAll(directories);
}
public void addIgnoredDirectoryImplicitly(@NotNull String path, @NotNull Project project) {
synchronized (myFilesToIgnore) {
if (myDirectoriesManuallyRemovedFromIgnored.contains(path) || myDirectoriesManuallyRemovedFromIgnored.contains(path + "/")) {
return;
}
for (IgnoredFileBean bean : myFilesToIgnore) {
if (bean.getType() == IgnoreSettingsType.UNDER_DIR && FileUtil.isAncestor(bean.getPath(), path, false)) {
return;
}
}
List<IgnoredFileBean> toRemove = new ArrayList<IgnoredFileBean>();
for (IgnoredFileBean bean : myFilesToIgnore) {
if ((bean.getType() == IgnoreSettingsType.UNDER_DIR || bean.getType() == IgnoreSettingsType.FILE) &&
FileUtil.isAncestor(path, bean.getPath(), false)) {
toRemove.add(bean);
}
}
myFilesToIgnore.removeAll(toRemove);
myFilesToIgnore.add(IgnoredBeanFactory.ignoreUnderDirectory(path, project));
}
}
private void addIgnoredFiles(final IgnoredFileBean... filesToIgnore) {
for (IgnoredFileBean bean : filesToIgnore) {
if (IgnoreSettingsType.FILE.equals(bean.getType())) {

Some files were not shown because too many files have changed in this diff Show More