mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -54,11 +54,12 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.DocumentImpl");
|
||||
|
||||
private final List<DocumentListener> myDocumentListeners = ContainerUtil.createEmptyCOWList();
|
||||
private final CopyOnWriteArrayList<DocumentListener> myDocumentListeners = ContainerUtil.createEmptyCOWList();
|
||||
private final RangeMarkerTree<RangeMarkerEx> myRangeMarkers = new RangeMarkerTree<RangeMarkerEx>(this);
|
||||
private final List<RangeMarker> myGuardedBlocks = new ArrayList<RangeMarker>();
|
||||
private ReadonlyFragmentModificationHandler myReadonlyFragmentModificationHandler;
|
||||
@@ -547,8 +548,8 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
|
||||
public void addDocumentListener(@NotNull DocumentListener listener) {
|
||||
myCachedDocumentListeners = null;
|
||||
LOG.assertTrue(!myDocumentListeners.contains(listener), listener);
|
||||
myDocumentListeners.add(listener);
|
||||
boolean added = myDocumentListeners.addIfAbsent(listener);
|
||||
LOG.assertTrue(added, listener);
|
||||
}
|
||||
|
||||
public void addDocumentListener(@NotNull final DocumentListener listener, @NotNull Disposable parentDisposable) {
|
||||
@@ -609,14 +610,16 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DocumentListener[] getCachedListeners() {
|
||||
if (myCachedDocumentListeners == null) {
|
||||
DocumentListener[] cachedListeners = myCachedDocumentListeners;
|
||||
if (cachedListeners == null) {
|
||||
DocumentListener[] listeners = myDocumentListeners.toArray(new DocumentListener[myDocumentListeners.size()]);
|
||||
Arrays.sort(listeners, PrioritizedDocumentListener.COMPARATOR);
|
||||
myCachedDocumentListeners = listeners;
|
||||
myCachedDocumentListeners = cachedListeners = listeners;
|
||||
}
|
||||
|
||||
return myCachedDocumentListeners;
|
||||
return cachedListeners;
|
||||
}
|
||||
|
||||
public void fireReadOnlyModificationAttempt() {
|
||||
|
||||
+9
-9
@@ -503,7 +503,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
@Override
|
||||
public void launchAction(@NotNull final IntentionAction action) {
|
||||
new WriteCommandAction(myProjectFixture.getProject()) {
|
||||
new WriteCommandAction(getProject()) {
|
||||
@Override
|
||||
protected void run(final Result result) throws Exception {
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(getFile(), getEditor(), action, action.getText());
|
||||
@@ -604,12 +604,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
final String newName,
|
||||
final boolean searchInComments,
|
||||
final boolean searchTextOccurrences) {
|
||||
new WriteCommandAction.Simple(myProjectFixture.getProject()) {
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final PsiElement substitution = RenamePsiElementProcessor.forElement(element).substituteElementToRename(element, myEditor);
|
||||
if (substitution == null) return;
|
||||
new RenameProcessor(myProjectFixture.getProject(), substitution, newName, searchInComments, searchTextOccurrences).run();
|
||||
new RenameProcessor(getProject(), substitution, newName, searchInComments, searchTextOccurrences).run();
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
@@ -739,7 +739,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@Override
|
||||
public void moveFile(@NonNls final String filePath, @NonNls final String to, final String... additionalFiles) {
|
||||
assertInitialized();
|
||||
final Project project = myProjectFixture.getProject();
|
||||
final Project project = getProject();
|
||||
new WriteCommandAction.Simple(project) {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
@@ -779,7 +779,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@NotNull
|
||||
public Collection<GutterIconRenderer> findAllGutters(final String filePath) {
|
||||
assertInitialized();
|
||||
final Project project = myProjectFixture.getProject();
|
||||
final Project project = getProject();
|
||||
final SortedMap<Integer, List<GutterIconRenderer>> result = new TreeMap<Integer, List<GutterIconRenderer>>();
|
||||
configureByFilesInner(filePath);
|
||||
|
||||
@@ -944,7 +944,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@Override
|
||||
public void checkResultByFile(final String expectedFile, final boolean ignoreTrailingWhitespaces) {
|
||||
assertInitialized();
|
||||
new WriteCommandAction.Simple(myProjectFixture.getProject()) {
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
@@ -957,7 +957,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
public void checkResultByFile(final String filePath, final String expectedFile, final boolean ignoreTrailingWhitespaces) {
|
||||
assertInitialized();
|
||||
|
||||
new WriteCommandAction.Simple(myProjectFixture.getProject()) {
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
@@ -1333,7 +1333,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@Override
|
||||
@NotNull
|
||||
public List<HighlightInfo> doHighlighting() {
|
||||
final Project project = myProjectFixture.getProject();
|
||||
final Project project = getProject();
|
||||
new WriteCommandAction.Simple(project) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
@@ -1538,7 +1538,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
final SelectionAndCaretMarkupLoader loader,
|
||||
String actualText) {
|
||||
assertInitialized();
|
||||
Project project = myProjectFixture.getProject();
|
||||
Project project = getProject();
|
||||
|
||||
project.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
|
||||
if (stripTrailingSpaces) {
|
||||
|
||||
+10
-10
@@ -53,6 +53,16 @@ class LightIdeaTestFixtureImpl extends BaseFixture implements LightIdeaTestFixtu
|
||||
storeSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
|
||||
checkForSettingsDamage();
|
||||
LightPlatformTestCase.doTearDown(getProject(), LightPlatformTestCase.getApplication(), true);
|
||||
super.tearDown();
|
||||
((InjectedLanguageManagerImpl)InjectedLanguageManager.getInstance(getProject())).checkInjectorsAreDisposed();
|
||||
}
|
||||
|
||||
|
||||
private class MyDataProvider implements DataProvider {
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -69,16 +79,6 @@ class LightIdeaTestFixtureImpl extends BaseFixture implements LightIdeaTestFixtu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
|
||||
checkForSettingsDamage();
|
||||
LightPlatformTestCase.doTearDown(getProject(), LightPlatformTestCase.getApplication(), true);
|
||||
super.tearDown();
|
||||
((InjectedLanguageManagerImpl)InjectedLanguageManager.getInstance(getProject())).checkInjectorsAreDisposed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return LightPlatformTestCase.getProject();
|
||||
|
||||
Reference in New Issue
Block a user