summaryrefslogtreecommitdiff
path: root/platform/core-api/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'platform/core-api/src/com')
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java26
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java23
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java37
-rw-r--r--platform/core-api/src/com/intellij/concurrency/JobScheduler.java3
-rw-r--r--platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java14
-rw-r--r--platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java8
-rw-r--r--platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java47
-rw-r--r--platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java3
-rw-r--r--platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java15
-rw-r--r--platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java1
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java2
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiFileFactory.java4
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiWalkingState.java7
-rw-r--r--platform/core-api/src/com/intellij/psi/ReferenceRange.java15
-rw-r--r--platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java7
15 files changed, 144 insertions, 68 deletions
diff --git a/platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
new file mode 100644
index 000000000000..3bb44937de4a
--- /dev/null
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
@@ -0,0 +1,26 @@
+/*
+ * 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.codeInsight.controlflow;
+
+import com.intellij.psi.PsiElement;
+
+/**
+ * @author oleg
+ */
+public interface ConditionalInstruction extends Instruction {
+ boolean getResult();
+ PsiElement getCondition();
+}
diff --git a/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
new file mode 100644
index 000000000000..bf72d011c6ea
--- /dev/null
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
@@ -0,0 +1,23 @@
+/*
+ * 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.codeInsight.controlflow;
+
+/**
+ * @author oleg
+ */
+public interface ControlFlow {
+ Instruction[] getInstructions();
+}
diff --git a/platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java
new file mode 100644
index 000000000000..8b0dda01d226
--- /dev/null
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java
@@ -0,0 +1,37 @@
+/*
+ * 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.codeInsight.controlflow;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+/**
+ * @author oleg
+ */
+public interface Instruction {
+ @Nullable
+ PsiElement getElement();
+
+ Collection<Instruction> allSucc();
+
+ Collection<Instruction> allPred();
+
+ String getElementPresentation();
+
+ int num();
+}
diff --git a/platform/core-api/src/com/intellij/concurrency/JobScheduler.java b/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
index a7e16644363c..30d668088824 100644
--- a/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
+++ b/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
@@ -81,8 +81,7 @@ public abstract class JobScheduler {
private static void enableRemoveOnCancelPolicy(ScheduledThreadPoolExecutor executor) {
if (Patches.USE_REFLECTION_TO_ACCESS_JDK7) {
try {
- Method setRemoveOnCancelPolicy = ScheduledThreadPoolExecutor.class.getDeclaredMethod("setRemoveOnCancelPolicy", boolean.class);
- setRemoveOnCancelPolicy.setAccessible(true);
+ Method setRemoveOnCancelPolicy = ReflectionUtil.getDeclaredMethod(ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
setRemoveOnCancelPolicy.invoke(executor, true);
}
catch (Exception ignored) {
diff --git a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
index 4dda4a664174..4a72e09dcd8e 100644
--- a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
+++ b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
@@ -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.
@@ -31,9 +31,11 @@ public interface ModalityInvokator {
*
* @param runnable the runnable to execute.
*/
- ActionCallback invokeLater(Runnable runnable);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable);
- ActionCallback invokeLater(Runnable runnable, @NotNull Condition expired);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired);
/**
* Causes <i>runnable.run()</i> to be executed asynchronously on the
@@ -43,7 +45,9 @@ public interface ModalityInvokator {
* @param runnable the runnable to execute.
* @param state the state in which the runnable will be executed.
*/
- ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state);
- ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired);
} \ No newline at end of file
diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
index 0f50f8d05ecf..afe440b8588f 100644
--- a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
+++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ public abstract class ProgressIndicatorProvider {
@Nullable
public static ProgressIndicatorProvider ourInstance;
- @Nullable
public static ProgressIndicatorProvider getInstance() {
return ourInstance;
}
@@ -39,6 +38,7 @@ public abstract class ProgressIndicatorProvider {
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
}
+ @NotNull
public abstract NonCancelableSection startNonCancelableSection();
@NotNull
@@ -46,12 +46,12 @@ public abstract class ProgressIndicatorProvider {
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY;
}
- public static volatile boolean ourNeedToCheckCancel = false;
+ protected static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) {
+ ourNeedToCheckCancel = false; // doCheckCanceled() may flip it back to true
ourInstance.doCheckCanceled();
- ourNeedToCheckCancel = false;
}
}
}
diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
index e99b8e6bebf0..4b4ace28cd37 100644
--- a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
+++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
@@ -25,38 +25,17 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-public abstract class ProgressManager {
- static {
- ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
- @Override
- public ProgressIndicator getProgressIndicator() {
- ProgressManager manager = ProgressManager.getInstance();
- return manager != null ? manager.getProgressIndicator() : null;
- }
-
- @Override
- protected void doCheckCanceled() throws ProcessCanceledException {
- ProgressManager manager = ProgressManager.getInstance();
- if (manager != null) {
- manager.doCheckCanceled();
- }
- }
-
- @Override
- public NonCancelableSection startNonCancelableSection() {
- ProgressManager manager = ProgressManager.getInstance();
- return manager != null ? manager.startNonCancelableSection() : NonCancelableSection.EMPTY;
- }
- };
+public abstract class ProgressManager extends ProgressIndicatorProvider {
+ public ProgressManager() {
+ ProgressIndicatorProvider.ourInstance = this;
}
- private static ProgressManager ourInstance;
+ private static class ProgressManagerHolder {
+ private static final ProgressManager ourInstance = ServiceManager.getService(ProgressManager.class);
+ }
public static ProgressManager getInstance() {
- if (ourInstance == null) {
- ourInstance = ServiceManager.getService(ProgressManager.class);
- }
- return ourInstance;
+ return ProgressManagerHolder.ourInstance;
}
public abstract boolean hasProgressIndicator();
@@ -66,17 +45,13 @@ public abstract class ProgressManager {
public abstract void runProcess(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException;
public abstract <T> T runProcess(@NotNull Computable<T> process, ProgressIndicator progress) throws ProcessCanceledException;
+ @Override
public ProgressIndicator getProgressIndicator() {
return myThreadIndicator.get();
}
- protected static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException {
- // smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
- if (ourNeedToCheckCancel) {
- getInstance().doCheckCanceled();
- ourNeedToCheckCancel = false;
- }
+ ProgressIndicatorProvider.checkCanceled();
}
public static void progress(@NotNull String text) throws ProcessCanceledException {
@@ -100,11 +75,7 @@ public abstract class ProgressManager {
}
}
- protected abstract void doCheckCanceled() throws ProcessCanceledException;
-
public abstract void executeNonCancelableSection(@NotNull Runnable runnable);
- @NotNull
- public abstract NonCancelableSection startNonCancelableSection();
public abstract void setCancelButtonText(String cancelButtonText);
diff --git a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
index 5232dc439b90..9b74576176fb 100644
--- a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
+++ b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.util;
import com.intellij.Patches;
+import com.intellij.util.xmlb.annotations.Transient;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@@ -28,6 +29,8 @@ public class SimpleModificationTracker implements ModificationTracker {
// fixed in JDK8
assert Patches.JDK_BUG_ID_7103570;
}
+
+ @Transient
public volatile int myCounter;
@Override
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
index 9e8c37880589..b3fc7550adfa 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
@@ -46,6 +46,8 @@ public class VfsUtilCore {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtilCore");
public static final String LOCALHOST_URI_PATH_PREFIX = "localhost/";
+ public static final char VFS_SEPARATOR_CHAR = '/';
+
private static final String PROTOCOL_DELIMITER = ":";
/**
@@ -118,6 +120,11 @@ public class VfsUtilCore {
return false;
}
+ @Nullable
+ public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor) {
+ return getRelativePath(file, ancestor, VFS_SEPARATOR_CHAR);
+ }
+
/**
* Gets the relative path of <code>file</code> to its <code>ancestor</code>. Uses <code>separator</code> for
* separating files.
@@ -129,12 +136,10 @@ public class VfsUtilCore {
*/
@Nullable
public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor, char separator) {
- if (!file.getFileSystem().equals(ancestor.getFileSystem())) return null;
-
- return doGetRelative(file, ancestor, separator);
- }
+ if (!file.getFileSystem().equals(ancestor.getFileSystem())) {
+ return null;
+ }
- public static String doGetRelative(VirtualFile file, VirtualFile ancestor, char separator) {
int length = 0;
VirtualFile parent = file;
while (true) {
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
index e4c3e5c502f5..d265d5a8cd2e 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
@@ -717,6 +717,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
putUserData(BOM_KEY, BOM);
}
+ @Override
@NonNls
public String toString() {
return "VirtualFile: " + getPresentableUrl();
diff --git a/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java b/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
index 205bf27fe1c0..4a2343ce2983 100644
--- a/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
+++ b/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
@@ -87,7 +87,7 @@ public class PsiElementResolveResult implements ResolveResult{
}
@NotNull
- public static ResolveResult[] createResults(@Nullable PsiElement[] elements) {
+ public static ResolveResult[] createResults(@Nullable PsiElement... elements) {
if (elements == null || elements.length == 0) return EMPTY_ARRAY;
final ResolveResult[] results = new ResolveResult[elements.length];
diff --git a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
index b31c03b6640a..e77ed1c3a4fb 100644
--- a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
+++ b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
@@ -63,6 +63,10 @@ public abstract class PsiFileFactory {
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text);
+ public PsiFile createFileFromText(@NotNull Language language, @NotNull CharSequence text) {
+ return createFileFromText("foo.bar", language, text);
+ }
+
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text,
boolean eventSystemEnabled, boolean markAsCopy);
diff --git a/platform/core-api/src/com/intellij/psi/PsiWalkingState.java b/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
index b6207e8bf364..6418a0b60804 100644
--- a/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
+++ b/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
@@ -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.
@@ -52,7 +52,10 @@ public abstract class PsiWalkingState extends WalkingState<PsiElement> {
}
protected PsiWalkingState(@NotNull PsiElementVisitor delegate) {
- super(PsiTreeGuide.instance);
+ this(delegate, PsiTreeGuide.instance);
+ }
+ protected PsiWalkingState(@NotNull PsiElementVisitor delegate, @NotNull TreeGuide<PsiElement> guide) {
+ super(guide);
myVisitor = delegate;
}
diff --git a/platform/core-api/src/com/intellij/psi/ReferenceRange.java b/platform/core-api/src/com/intellij/psi/ReferenceRange.java
index cfb1f49a71e7..1ac18336abcb 100644
--- a/platform/core-api/src/com/intellij/psi/ReferenceRange.java
+++ b/platform/core-api/src/com/intellij/psi/ReferenceRange.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.
@@ -20,6 +20,7 @@
package com.intellij.psi;
import com.intellij.openapi.util.TextRange;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,14 +30,16 @@ public class ReferenceRange {
private ReferenceRange() {
}
- public static List<TextRange> getRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getRanges(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
return ((MultiRangeReference)ref).getRanges();
}
return Collections.singletonList(ref.getRangeInElement());
}
- public static List<TextRange> getAbsoluteRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getAbsoluteRanges(@NotNull PsiReference ref) {
final PsiElement elt = ref.getElement();
final List<TextRange> relativeRanges = getRanges(ref);
final List<TextRange> answer = new ArrayList<TextRange>(relativeRanges.size());
@@ -47,7 +50,7 @@ public class ReferenceRange {
return answer;
}
- public static TextRange getRange(PsiReference ref) {
+ public static TextRange getRange(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
final List<TextRange> ranges = ((MultiRangeReference)ref).getRanges();
return new TextRange(ranges.get(0).getStartOffset(), ranges.get(ranges.size() - 1).getEndOffset());
@@ -56,7 +59,7 @@ public class ReferenceRange {
return ref.getRangeInElement();
}
- public static boolean containsOffsetInElement(PsiReference ref, int offset) {
+ public static boolean containsOffsetInElement(@NotNull PsiReference ref, int offset) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.containsOffset(offset)) return true;
@@ -68,7 +71,7 @@ public class ReferenceRange {
return rangeInElement != null && rangeInElement.containsOffset(offset);
}
- public static boolean containsRangeInElement(PsiReference ref, TextRange rangeInElement) {
+ public static boolean containsRangeInElement(@NotNull PsiReference ref, @NotNull TextRange rangeInElement) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.contains(rangeInElement)) return true;
diff --git a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
index bc518e1b66a3..982d921b9e97 100644
--- a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
+++ b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
@@ -19,10 +19,7 @@ import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.CharsetUtil;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
-import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
-import com.intellij.openapi.vfs.VfsUtilCore;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileSystem;
+import com.intellij.openapi.vfs.*;
import com.intellij.util.LocalTimeCounter;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -113,7 +110,7 @@ public class LightVirtualFile extends VirtualFile {
myOriginalFile = originalFile;
}
- private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem {
+ private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem implements NonPhysicalFileSystem{
@NonNls private static final String PROTOCOL = "mock";
private MyVirtualFileSystem() {