summaryrefslogtreecommitdiff
path: root/platform/lang-api/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-api/src/com')
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/completion/CompletionInitializationContext.java22
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java7
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java36
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java9
-rw-r--r--platform/lang-api/src/com/intellij/find/FindManager.java12
-rw-r--r--platform/lang-api/src/com/intellij/find/FindModel.java107
-rw-r--r--platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java10
-rw-r--r--platform/lang-api/src/com/intellij/lexer/LexerUtil.java10
-rw-r--r--platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java22
-rw-r--r--platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java1
10 files changed, 183 insertions, 53 deletions
diff --git a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionInitializationContext.java b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionInitializationContext.java
index 624d60fd8688..2c152b595421 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionInitializationContext.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionInitializationContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 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.
@@ -16,8 +16,8 @@
package com.intellij.codeInsight.completion;
import com.intellij.lang.Language;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
@@ -45,26 +45,24 @@ public class CompletionInitializationContext {
private final OffsetMap myOffsetMap;
private String myDummyIdentifier = DUMMY_IDENTIFIER;
- public CompletionInitializationContext(final Editor editor, final PsiFile file, final CompletionType completionType, int invocationCount) {
+ public CompletionInitializationContext(final Editor editor, final Caret caret, final PsiFile file, final CompletionType completionType, int invocationCount) {
myEditor = editor;
myFile = file;
myCompletionType = completionType;
myInvocationCount = invocationCount;
myOffsetMap = new OffsetMap(editor.getDocument());
- myOffsetMap.addOffset(START_OFFSET, calcStartOffset(editor));
- myOffsetMap.addOffset(SELECTION_END_OFFSET, calcSelectionEnd(editor));
- myOffsetMap.addOffset(IDENTIFIER_END_OFFSET, calcDefaultIdentifierEnd(editor, calcSelectionEnd(editor)));
+ myOffsetMap.addOffset(START_OFFSET, calcStartOffset(caret));
+ myOffsetMap.addOffset(SELECTION_END_OFFSET, calcSelectionEnd(caret));
+ myOffsetMap.addOffset(IDENTIFIER_END_OFFSET, calcDefaultIdentifierEnd(editor, calcSelectionEnd(caret)));
}
- private static int calcSelectionEnd(Editor editor) {
- final SelectionModel selectionModel = editor.getSelectionModel();
- return selectionModel.hasSelection() ? selectionModel.getSelectionEnd() : editor.getCaretModel().getOffset();
+ private static int calcSelectionEnd(Caret caret) {
+ return caret.hasSelection() ? caret.getSelectionEnd() : caret.getOffset();
}
- public static int calcStartOffset(Editor editor) {
- final SelectionModel selectionModel = editor.getSelectionModel();
- return selectionModel.hasSelection() ? selectionModel.getSelectionStart() : editor.getCaretModel().getOffset();
+ public static int calcStartOffset(Caret caret) {
+ return caret.hasSelection() ? caret.getSelectionStart() : caret.getOffset();
}
static int calcDefaultIdentifierEnd(Editor editor, int startFrom) {
diff --git a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java
index 8a7feb2109fe..6cccc06dacf2 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.StandardPatterns;
import com.intellij.util.Consumer;
+import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedHashSet;
@@ -61,7 +62,6 @@ public abstract class CompletionResultSet implements Consumer<LookupElement> {
/**
* If a given element matches the prefix, give it for further processing (which may eventually result in its appearing in the completion list)
- * @param element
*/
public abstract void addElement(@NotNull final LookupElement element);
@@ -75,15 +75,17 @@ public abstract class CompletionResultSet implements Consumer<LookupElement> {
}
}
+ @Contract(value="", pure=true)
@NotNull public abstract CompletionResultSet withPrefixMatcher(@NotNull PrefixMatcher matcher);
/**
* Creates a default camel-hump prefix matcher based on given prefix
- * @param prefix
*/
+ @Contract(value="", pure=true)
@NotNull public abstract CompletionResultSet withPrefixMatcher(@NotNull String prefix);
@NotNull
+ @Contract(value="", pure=true)
public abstract CompletionResultSet withRelevanceSorter(@NotNull CompletionSorter sorter);
public abstract void addLookupAdvertisement(@NotNull String text);
@@ -92,6 +94,7 @@ public abstract class CompletionResultSet implements Consumer<LookupElement> {
* @return A result set with the same prefix, but the lookup strings will be matched case-insensitively. Their lookup strings will
* remain as they are though, so upon insertion the prefix case will be changed.
*/
+ @Contract(value="", pure=true)
@NotNull public abstract CompletionResultSet caseInsensitive();
@NotNull
diff --git a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java
index 189e6581d171..771ca526b5fe 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/lookup/LookupElementBuilder.java
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.util.PsiUtilCore;
import gnu.trove.THashSet;
+import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -85,10 +86,12 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withInsertHandler(com.intellij.codeInsight.completion.InsertHandler)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setInsertHandler(@Nullable InsertHandler<LookupElement> insertHandler) {
return withInsertHandler(insertHandler);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withInsertHandler(@Nullable InsertHandler<LookupElement> insertHandler) {
return new LookupElementBuilder(myLookupString, myObject, insertHandler, myRenderer, myHardcodedPresentation,
myAllLookupStrings, myCaseSensitive);
@@ -97,9 +100,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withRenderer(LookupElementRenderer)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setRenderer(@Nullable LookupElementRenderer<LookupElement> renderer) {
return withRenderer(renderer);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withRenderer(@Nullable LookupElementRenderer<LookupElement> renderer) {
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, renderer, myHardcodedPresentation,
myAllLookupStrings, myCaseSensitive);
@@ -114,10 +119,12 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withIcon(javax.swing.Icon)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setIcon(@Nullable Icon icon) {
return withIcon(icon);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withIcon(@Nullable Icon icon) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setIcon(icon);
@@ -139,9 +146,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withLookupString(String)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder addLookupString(@NotNull String another) {
return withLookupString(another);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withLookupString(@NotNull String another) {
final THashSet<String> set = new THashSet<String>(myAllLookupStrings);
set.add(another);
@@ -157,6 +166,7 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withCaseSensitivity(boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setCaseSensitive(boolean caseSensitive) {
return withCaseSensitivity(caseSensitive);
}
@@ -165,6 +175,7 @@ public final class LookupElementBuilder extends LookupElement {
* @return modified builder
* @see com.intellij.codeInsight.completion.CompletionResultSet#caseInsensitive()
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder withCaseSensitivity(boolean caseSensitive) {
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, myRenderer, myHardcodedPresentation,
myAllLookupStrings, caseSensitive);
@@ -173,9 +184,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withItemTextForeground(java.awt.Color)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setItemTextForeground(@NotNull Color itemTextForeground) {
return withItemTextForeground(itemTextForeground);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withItemTextForeground(@NotNull Color itemTextForeground) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setItemTextForeground(itemTextForeground);
@@ -185,9 +198,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withItemTextUnderlined(boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setItemTextUnderlined(boolean underlined) {
return withItemTextUnderlined(underlined);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withItemTextUnderlined(boolean underlined) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setItemTextUnderlined(underlined);
@@ -197,9 +212,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withTypeText(String)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setTypeText(@Nullable String typeText) {
return withTypeText(typeText);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withTypeText(@Nullable String typeText) {
return withTypeText(typeText, false);
}
@@ -207,14 +224,17 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withTypeText(String, boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setTypeText(@Nullable String typeText, boolean grayed) {
return withTypeText(typeText, grayed);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withTypeText(@Nullable String typeText, boolean grayed) {
return withTypeText(typeText, null, grayed);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withTypeText(@Nullable String typeText, @Nullable Icon typeIcon, boolean grayed) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setTypeText(typeText, typeIcon);
@@ -226,9 +246,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withPresentableText(String)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setPresentableText(@NotNull String presentableText) {
return withPresentableText(presentableText);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withPresentableText(@NotNull String presentableText) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setItemText(presentableText);
@@ -239,9 +261,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #bold()}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setBold() {
return bold();
}
+ @Contract(value="", pure=true)
public LookupElementBuilder bold() {
return withBoldness(true);
}
@@ -249,9 +273,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withBoldness(boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setBold(boolean bold) {
return withBoldness(bold);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withBoldness(boolean bold) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setItemTextBold(bold);
@@ -262,9 +288,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #strikeout()}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setStrikeout() {
return strikeout();
}
+ @Contract(value="", pure=true)
public LookupElementBuilder strikeout() {
return withStrikeoutness(true);
}
@@ -272,9 +300,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withStrikeoutness(boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setStrikeout(boolean strikeout) {
return withStrikeoutness(strikeout);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withStrikeoutness(boolean strikeout) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setStrikeout(strikeout);
@@ -285,9 +315,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withTailText(String)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setTailText(@Nullable String tailText) {
return withTailText(tailText);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withTailText(@Nullable String tailText) {
return withTailText(tailText, false);
}
@@ -295,9 +327,11 @@ public final class LookupElementBuilder extends LookupElement {
/**
* @deprecated use {@link #withTailText(String, boolean)}
*/
+ @Contract(value="", pure=true)
public LookupElementBuilder setTailText(@Nullable String tailText, boolean grayed) {
return withTailText(tailText, grayed);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder withTailText(@Nullable String tailText, boolean grayed) {
final LookupElementPresentation presentation = copyPresentation();
presentation.setTailText(tailText, grayed);
@@ -305,12 +339,14 @@ public final class LookupElementBuilder extends LookupElement {
myAllLookupStrings, myCaseSensitive);
}
+ @Contract(value="", pure=true)
public LookupElementBuilder appendTailText(@NotNull String tailText, boolean grayed) {
final LookupElementPresentation presentation = copyPresentation();
presentation.appendTailText(tailText, grayed);
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation, myAllLookupStrings, myCaseSensitive);
}
+ @Contract(value="", pure=true)
public LookupElement withAutoCompletionPolicy(AutoCompletionPolicy policy) {
return policy.applyPolicy(this);
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
index efee74b807da..8d4d3b29b088 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
@@ -142,14 +142,15 @@ public class RunContentDescriptor implements Disposable {
return myContent;
}
- public void setRestarter(Runnable runnable) {
- myRestarter = runnable;
- }
-
+ @Nullable
public Runnable getRestarter() {
return myRestarter;
}
+ public void setRestarter(@Nullable Runnable runnable) {
+ myRestarter = runnable;
+ }
+
public boolean isActivateToolWindowWhenAdded() {
return myActivateToolWindowWhenAdded;
}
diff --git a/platform/lang-api/src/com/intellij/find/FindManager.java b/platform/lang-api/src/com/intellij/find/FindManager.java
index 56339d116e14..abf90bb4f0b7 100644
--- a/platform/lang-api/src/com/intellij/find/FindManager.java
+++ b/platform/lang-api/src/com/intellij/find/FindManager.java
@@ -172,6 +172,18 @@ public abstract class FindManager {
public abstract void setFindWasPerformed();
/**
+ * Gets the flag indicating that 'Add Selection for Next Occurrence' action was performed recently,
+ * so "Find Next" and "Find Previous" actions should work in its context.
+ */
+ public abstract boolean selectNextOccurrenceWasPerformed();
+
+ /**
+ * Sets the flag indicating that 'Add Selection for Next Occurrence' action was performed recently,
+ * so "Find Next" and "Find Previous" actions should work in its context.
+ */
+ public abstract void setSelectNextOccurrenceWasPerformed();
+
+ /**
* Explicitly tell FindManager that "Find Next" and "Find Previous" actions should not use
* find usages previous results.
*/
diff --git a/platform/lang-api/src/com/intellij/find/FindModel.java b/platform/lang-api/src/com/intellij/find/FindModel.java
index a09070c1ed24..5dafc2db8acf 100644
--- a/platform/lang-api/src/com/intellij/find/FindModel.java
+++ b/platform/lang-api/src/com/intellij/find/FindModel.java
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.search.SearchScope;
+import com.intellij.util.PatternUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -72,8 +73,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;
@@ -96,6 +96,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
private SearchScope customScope;
private boolean isCustomScope = false;
private boolean isMultiline = false;
+ private boolean mySearchInProjectFiles;
public boolean isMultiline() {
return isMultiline;
@@ -170,8 +171,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;
}
@@ -190,8 +190,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;
@@ -215,6 +215,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
if (myStringToReplace != null ? !myStringToReplace.equals(findModel.myStringToReplace) : findModel.myStringToReplace != null) {
return false;
}
+ if (mySearchInProjectFiles != findModel.mySearchInProjectFiles) return false;
return true;
}
@@ -227,8 +228,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);
@@ -252,6 +252,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
result = 31 * result + (isCustomScope ? 1 : 0);
result = 31 * result + (isMultiline ? 1 : 0);
result = 31 * result + (isPreserveCase ? 1 : 0);
+ result = 31 * result + (mySearchInProjectFiles ? 1 : 0);
result = 31 * result + (myPattern != null ? myPattern.hashCode() : 0);
return result;
}
@@ -274,7 +275,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
public void setStringToFind(@NotNull String s) {
boolean changed = !StringUtil.equals(s, myStringToFind);
myStringToFind = s;
- myPattern = NO_PATTERN;
+ myPattern = PatternUtil.NOTHING;
if (changed) {
notifyObservers();
}
@@ -409,7 +410,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
boolean changed = val != isCaseSensitive;
isCaseSensitive = val;
if (changed) {
- myPattern = NO_PATTERN;
+ myPattern = PatternUtil.NOTHING;
notifyObservers();
}
}
@@ -658,8 +659,8 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
}
@Override
- public Object clone() {
- return super.clone();
+ public FindModel clone() {
+ return (FindModel)super.clone();
}
@@ -670,8 +671,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");
@@ -689,6 +689,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
buffer.append("fileFilter =").append(fileFilter).append("\n");
buffer.append("moduleName =").append(moduleName).append("\n");
buffer.append("customScopeName =").append(customScopeName).append("\n");
+ buffer.append("searchInProjectFiles =").append(mySearchInProjectFiles).append("\n");
return buffer.toString();
}
@@ -849,45 +850,95 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
}
}
+ public enum SearchContext {
+ ANY, IN_STRING_LITERALS, IN_COMMENTS, EXCEPT_STRING_LITERALS, EXCEPT_COMMENTS, EXCEPT_COMMENTS_AND_STRING_LITERALS
+ }
+
public boolean isInStringLiteralsOnly() {
- return isInStringLiteralsOnly;
+ return searchContext == SearchContext.IN_STRING_LITERALS;
+ }
+
+ public boolean isExceptComments() {
+ return searchContext == SearchContext.EXCEPT_COMMENTS;
+ }
+
+ public boolean isExceptStringLiterals() {
+ return searchContext == SearchContext.EXCEPT_STRING_LITERALS;
+ }
+
+ public boolean isInCommentsOnly() {
+ return searchContext == SearchContext.IN_COMMENTS;
+ }
+
+ public boolean isExceptCommentsAndStringLiterals() {
+ return searchContext == SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS;
+ }
+
+ @Deprecated
+ public void setInCommentsOnly(boolean inCommentsOnly) {
+ doApplyContextChange(inCommentsOnly, SearchContext.IN_COMMENTS);
}
+ @Deprecated
public void setInStringLiteralsOnly(boolean inStringLiteralsOnly) {
- boolean changed = isInStringLiteralsOnly != inStringLiteralsOnly;
- isInStringLiteralsOnly = inStringLiteralsOnly;
+ doApplyContextChange(inStringLiteralsOnly, SearchContext.IN_STRING_LITERALS);
+ }
+
+ private void doApplyContextChange(boolean newOptionValue, SearchContext option) {
+ boolean changed = false;
+ if (newOptionValue) {
+ changed = searchContext != option;
+ searchContext = option;
+ } else if (searchContext == option) { // do not reset unrelated value
+ changed = true;
+ searchContext = SearchContext.ANY;
+ }
+
if (changed) {
notifyObservers();
}
}
- public boolean isInCommentsOnly() {
- return isInCommentsOnly;
+ public @NotNull SearchContext getSearchContext() {
+ return searchContext;
}
- public void setInCommentsOnly(boolean inCommentsOnly) {
- boolean changed = isInCommentsOnly != inCommentsOnly;
- isInCommentsOnly = inCommentsOnly;
+ public void setSearchContext(@NotNull SearchContext _searchContext) {
+ doSetContext(_searchContext);
+ }
+
+ private void doSetContext(SearchContext newSearchContext) {
+ boolean changed = newSearchContext != searchContext;
+ searchContext = newSearchContext;
+ if (changed) {
+ notifyObservers();
+ }
+ }
+
+ public boolean isSearchInProjectFiles() {
+ return mySearchInProjectFiles;
+ }
+
+ public void setSearchInProjectFiles(boolean searchInProjectFiles) {
+ boolean changed = mySearchInProjectFiles != searchInProjectFiles;
+ mySearchInProjectFiles = searchInProjectFiles;
if (changed) {
notifyObservers();
}
}
- private static final Pattern NO_PATTERN = Pattern.compile("");
- private Pattern myPattern = NO_PATTERN;
+ private Pattern myPattern = PatternUtil.NOTHING;
public Pattern compileRegExp() {
String toFind = getStringToFind();
Pattern pattern = myPattern;
- if (pattern == NO_PATTERN) {
+ if (pattern == PatternUtil.NOTHING) {
try {
myPattern = pattern = Pattern.compile(toFind, isCaseSensitive() ? Pattern.MULTILINE : Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
}
catch (PatternSyntaxException e) {
- LOG.error("Regexp:'" + toFind + "'", e);
- myPattern = null;
- return null;
+ myPattern = pattern = null;
}
}
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
index bb8a60c83479..6f23ac69f745 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.platform.ProjectTemplate;
import com.intellij.util.SystemProperties;
@@ -48,6 +49,7 @@ public class WizardContext extends UserDataHolderBase {
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private StorageScheme myProjectStorageFormat = StorageScheme.DIRECTORY_BASED;
private boolean myNewWizard;
+ private ModulesProvider myModulesProvider;
public void setProjectStorageFormat(StorageScheme format) {
myProjectStorageFormat = format;
@@ -61,6 +63,14 @@ public class WizardContext extends UserDataHolderBase {
myNewWizard = newWizard;
}
+ public ModulesProvider getModulesProvider() {
+ return myModulesProvider;
+ }
+
+ public void setModulesProvider(ModulesProvider modulesProvider) {
+ myModulesProvider = modulesProvider;
+ }
+
public interface Listener {
void buttonsUpdateRequested();
void nextStepRequested();
diff --git a/platform/lang-api/src/com/intellij/lexer/LexerUtil.java b/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
index 7623248e60d1..8abdfa5e79af 100644
--- a/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
+++ b/platform/lang-api/src/com/intellij/lexer/LexerUtil.java
@@ -16,6 +16,8 @@
package com.intellij.lexer;
import com.intellij.util.CharTable;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
/**
* @author max
@@ -30,4 +32,12 @@ public class LexerUtil {
public static CharSequence internToken(Lexer lexer, CharTable table) {
return table.intern(getTokenText(lexer));
}
+
+ @Contract("!null->!null")
+ public static Lexer getRootLexer(@Nullable Lexer lexer) {
+ while (lexer instanceof DelegateLexer) {
+ lexer = ((DelegateLexer)lexer).getDelegate();
+ }
+ return lexer;
+ }
}
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
index 2c44a32d9ace..d858bfc01fcb 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
@@ -56,7 +56,6 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
public CodeStyleSettings(boolean loadExtensions) {
super(null);
- RIGHT_MARGIN = DEFAULT_RIGHT_MARGIN;
initTypeToName();
initImportsByDefault();
@@ -108,12 +107,16 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
private void addCustomSettings(CustomCodeStyleSettings settings) {
if (settings != null) {
- myCustomSettings.put(settings.getClass(), settings);
+ synchronized (myCustomSettings) {
+ myCustomSettings.put(settings.getClass(), settings);
+ }
}
}
public <T extends CustomCodeStyleSettings> T getCustomSettings(Class<T> aClass) {
- return (T)myCustomSettings.get(aClass);
+ synchronized (myCustomSettings) {
+ return (T)myCustomSettings.get(aClass);
+ }
}
@Override
@@ -125,7 +128,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
private void copyCustomSettingsFrom(@NotNull CodeStyleSettings from) {
myCustomSettings.clear();
- for (final CustomCodeStyleSettings settings : from.myCustomSettings.values()) {
+ for (final CustomCodeStyleSettings settings : from.getCustomSettingsValues()) {
addCustomSettings((CustomCodeStyleSettings) settings.clone());
}
@@ -244,6 +247,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
public int INNER_CLASSES_ORDER_WEIGHT = 7;
//----------------- WRAPPING ---------------------------
+ public int RIGHT_MARGIN = 120;
public boolean WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = false;
@@ -431,6 +435,12 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
private CodeStyleSettings myParentSettings;
private boolean myLoadedAdditionalIndentOptions;
+ private Collection<CustomCodeStyleSettings> getCustomSettingsValues() {
+ synchronized (myCustomSettings) {
+ return Collections.unmodifiableCollection(myCustomSettings.values());
+ }
+ }
+
@Override
public void readExternal(Element element) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, element);
@@ -452,7 +462,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
}
}
boolean oldOptionsImported = importOldIndentOptions(element);
- for (final CustomCodeStyleSettings settings : myCustomSettings.values()) {
+ for (final CustomCodeStyleSettings settings : getCustomSettingsValues()) {
settings.readExternal(element);
settings.importLegacySettings();
}
@@ -564,7 +574,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
public void writeExternal(Element element) throws WriteExternalException {
final CodeStyleSettings parentSettings = new CodeStyleSettings();
DefaultJDOMExternalizer.writeExternal(this, element, new DifferenceFilter<CodeStyleSettings>(this, parentSettings));
- List<CustomCodeStyleSettings> customSettings = new ArrayList<CustomCodeStyleSettings>(myCustomSettings.values());
+ List<CustomCodeStyleSettings> customSettings = new ArrayList<CustomCodeStyleSettings>(getCustomSettingsValues());
Collections.sort(customSettings, new Comparator<CustomCodeStyleSettings>(){
@Override
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
index 20b96cac3920..299d17215fdf 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java
@@ -287,7 +287,6 @@ public class CommonCodeStyleSettings {
//----------------- GENERAL --------------------
public int RIGHT_MARGIN = -1;
- public final static int DEFAULT_RIGHT_MARGIN = 120;
public boolean LINE_COMMENT_AT_FIRST_COLUMN = true;
public boolean BLOCK_COMMENT_AT_FIRST_COLUMN = true;