mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -41,7 +41,7 @@ class CanBeFinalAnnotator extends RefGraphAnnotatorEx {
|
||||
public void onInitialize(RefElement refElement) {
|
||||
((RefElementImpl)refElement).setFlag(true, CAN_BE_FINAL_MASK);
|
||||
if (refElement instanceof RefClass) {
|
||||
final RefClass refClass = ((RefClass)refElement);
|
||||
final RefClass refClass = (RefClass)refElement;
|
||||
final PsiClass psiClass = refClass.getElement();
|
||||
if (RefUtil.isEntryPoint(refClass)) {
|
||||
((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK);
|
||||
|
||||
@@ -32,12 +32,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public abstract class RefJavaElementImpl extends RefElementImpl implements RefJavaElement {
|
||||
private static final HashSet<RefClass> EMPTY_TYPE_REFERENCES_LIST = new HashSet<RefClass>(0);
|
||||
private THashSet<RefClass> myOutTypeReferences;
|
||||
private Set<RefClass> myOutTypeReferences;
|
||||
private static final int ACCESS_MODIFIER_MASK = 0x03;
|
||||
private static final int ACCESS_PRIVATE = 0x00;
|
||||
private static final int ACCESS_PROTECTED = 0x01;
|
||||
@@ -51,22 +51,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
protected RefJavaElementImpl(String name, RefJavaElement owner) {
|
||||
super(name, owner);
|
||||
String am = owner.getAccessModifier();
|
||||
final int access_id;
|
||||
|
||||
if (PsiModifier.PRIVATE.equals(am)) {
|
||||
access_id = ACCESS_PRIVATE;
|
||||
}
|
||||
else if (PsiModifier.PUBLIC.equals(am)) {
|
||||
access_id = ACCESS_PUBLIC;
|
||||
}
|
||||
else if (PsiModifier.PACKAGE_LOCAL.equals(am)) {
|
||||
access_id = ACCESS_PACKAGE;
|
||||
}
|
||||
else {
|
||||
access_id = ACCESS_PROTECTED;
|
||||
}
|
||||
|
||||
myFlags = ((myFlags >> 2) << 2) | access_id;
|
||||
doSetAccessModifier(am);
|
||||
|
||||
final boolean synthOwner = owner.isSyntheticJSP();
|
||||
if (synthOwner) {
|
||||
@@ -102,7 +87,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
@NotNull
|
||||
public Collection<RefClass> getOutTypeReferences() {
|
||||
if (myOutTypeReferences == null){
|
||||
return EMPTY_TYPE_REFERENCES_LIST;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return myOutTypeReferences;
|
||||
}
|
||||
@@ -118,7 +103,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
if (element instanceof PsiAnonymousClass) {
|
||||
PsiAnonymousClass psiAnonymousClass = (PsiAnonymousClass)element;
|
||||
PsiClass psiBaseClass = psiAnonymousClass.getBaseClassType().resolve();
|
||||
return InspectionsBundle.message("inspection.reference.anonymous.name", (psiBaseClass != null ? psiBaseClass.getQualifiedName() : ""));
|
||||
return InspectionsBundle.message("inspection.reference.anonymous.name", psiBaseClass == null ? "" : psiBaseClass.getQualifiedName());
|
||||
}
|
||||
|
||||
if (element instanceof JspClass) {
|
||||
@@ -175,6 +160,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
setFlag(b, IS_SYNTHETIC_JSP_ELEMENT);
|
||||
}
|
||||
|
||||
@Modifier
|
||||
@Nullable
|
||||
public String getAccessModifier() {
|
||||
long access_id = myFlags & ACCESS_MODIFIER_MASK;
|
||||
@@ -185,6 +171,10 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
}
|
||||
|
||||
public void setAccessModifier(String am) {
|
||||
doSetAccessModifier(am);
|
||||
}
|
||||
|
||||
private void doSetAccessModifier(String am) {
|
||||
final int access_id;
|
||||
|
||||
if (PsiModifier.PRIVATE.equals(am)) {
|
||||
@@ -200,7 +190,7 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
access_id = ACCESS_PROTECTED;
|
||||
}
|
||||
|
||||
myFlags = ((myFlags >> 2) << 2) | access_id;
|
||||
myFlags = myFlags & ~0x3 | access_id;
|
||||
}
|
||||
|
||||
public boolean isSuspiciousRecursive() {
|
||||
@@ -209,12 +199,12 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
|
||||
private boolean isCalledOnlyFrom(RefJavaElement refElement, Stack<RefJavaElement> callStack) {
|
||||
if (callStack.contains(this)) return refElement == this;
|
||||
if (getInReferences().size() == 0) return false;
|
||||
if (getInReferences().isEmpty()) return false;
|
||||
|
||||
if (refElement instanceof RefMethod) {
|
||||
RefMethod refMethod = (RefMethod) refElement;
|
||||
for (RefMethod refSuper : refMethod.getSuperMethods()) {
|
||||
if (refSuper.getInReferences().size() > 0) return false;
|
||||
if (!refSuper.getInReferences().isEmpty()) return false;
|
||||
}
|
||||
if (refMethod.isConstructor()){
|
||||
boolean unreachable = true;
|
||||
@@ -241,10 +231,10 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
if (refWhat != null) {
|
||||
if (refWhat instanceof RefParameter) {
|
||||
if (forWriting) {
|
||||
((RefParameterImpl)refWhat).parameterReferenced(true);
|
||||
((RefParameter)refWhat).parameterReferenced(true);
|
||||
}
|
||||
if (forReading) {
|
||||
((RefParameterImpl)refWhat).parameterReferenced(false);
|
||||
((RefParameter)refWhat).parameterReferenced(false);
|
||||
}
|
||||
}
|
||||
addOutReference(refWhat);
|
||||
@@ -278,4 +268,4 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa
|
||||
}
|
||||
return super.getIcon(expanded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,5 +71,5 @@ public interface RefJavaElement extends RefElement {
|
||||
*/
|
||||
@Nullable
|
||||
@Modifier
|
||||
String getAccessModifier();
|
||||
String getAccessModifier();
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public abstract class PsiDocumentManager {
|
||||
*
|
||||
* @param document the document to commit.
|
||||
*/
|
||||
public abstract void commitDocument(Document document);
|
||||
public abstract void commitDocument(@NotNull Document document);
|
||||
|
||||
/**
|
||||
* Returns the list of documents which have been modified but not committed.
|
||||
@@ -102,6 +102,7 @@ public abstract class PsiDocumentManager {
|
||||
* @return the list of uncommitted documents.
|
||||
* @see #commitDocument(com.intellij.openapi.editor.Document)
|
||||
*/
|
||||
@NotNull
|
||||
public abstract Document[] getUncommittedDocuments();
|
||||
|
||||
/**
|
||||
@@ -111,7 +112,7 @@ public abstract class PsiDocumentManager {
|
||||
* @return true if the document was modified but not committed, false otherwise
|
||||
* @see #commitDocument(com.intellij.openapi.editor.Document)
|
||||
*/
|
||||
public abstract boolean isUncommited(Document document);
|
||||
public abstract boolean isUncommited(@NotNull Document document);
|
||||
|
||||
/**
|
||||
* Checks if any modified documents have not been committed.
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class PsiRecursiveElementVisitor extends PsiElementVisitor {
|
||||
private final boolean myVisitAllFileRoots;
|
||||
private int level = 0;
|
||||
private static final int MAX_LEVEL_DEPTH = 200; // all elements beneath this level are ignored to avoid stack overflow
|
||||
|
||||
protected PsiRecursiveElementVisitor() {
|
||||
this(false);
|
||||
@@ -37,13 +35,8 @@ public abstract class PsiRecursiveElementVisitor extends PsiElementVisitor {
|
||||
}
|
||||
|
||||
public void visitElement(final PsiElement element) {
|
||||
level++;
|
||||
if (level < MAX_LEVEL_DEPTH) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
level--;
|
||||
ProgressManager.checkCanceled();
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,6 +47,7 @@ public abstract class PsiRecursiveElementVisitor extends PsiElementVisitor {
|
||||
if (allFiles.size() > 1) {
|
||||
if (file == viewProvider.getPsi(viewProvider.getBaseLanguage())) {
|
||||
for (PsiFile lFile : allFiles) {
|
||||
ProgressManager.checkCanceled();
|
||||
lFile.acceptChildren(this);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class RefEntityImpl implements RefEntity {
|
||||
protected ArrayList<RefEntity> myChildren;
|
||||
private final String myName;
|
||||
private THashMap myUserMap = null;
|
||||
protected long myFlags = 0;
|
||||
protected int myFlags = 0;
|
||||
protected final RefManagerImpl myManager;
|
||||
|
||||
protected RefEntityImpl(String name, final RefManager manager) {
|
||||
@@ -118,7 +118,7 @@ public abstract class RefEntityImpl implements RefEntity {
|
||||
}
|
||||
else{
|
||||
myUserMap.remove(key);
|
||||
if (myUserMap.size() == 0){
|
||||
if (myUserMap.isEmpty()){
|
||||
myUserMap = null;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,8 @@ public abstract class RefEntityImpl implements RefEntity {
|
||||
public void setFlag(boolean b, int mask) {
|
||||
if (b) {
|
||||
myFlags |= mask;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myFlags &= ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
+37
-33
@@ -47,7 +47,6 @@ import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.packageDependencies.ui.TreeExpansionMonitor;
|
||||
import com.intellij.profile.ProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -72,7 +71,10 @@ import javax.swing.event.TreeExpansionEvent;
|
||||
import javax.swing.event.TreeExpansionListener;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.DefaultTreeSelectionModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -95,7 +97,6 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
private InspectionProfileImpl mySelectedProfile;
|
||||
private JEditorPane myBrowser;
|
||||
private JPanel myOptionsPanel;
|
||||
private final UserActivityWatcher myUserActivityWatcher = new UserActivityWatcher();
|
||||
private final JPanel myInspectionProfilePanel = new JPanel(new BorderLayout());
|
||||
private FilterComponent myProfileFilter;
|
||||
private final InspectionConfigTreeNode myRoot =
|
||||
@@ -121,7 +122,8 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
mySelectedProfile = (InspectionProfileImpl)profile;
|
||||
myInitialProfile = inspectionProfileName;
|
||||
add(createInspectionProfileSettingsPanel(), BorderLayout.CENTER);
|
||||
myUserActivityWatcher.addUserActivityListener(new UserActivityListener() {
|
||||
UserActivityWatcher userActivityWatcher = new UserActivityWatcher();
|
||||
userActivityWatcher.addUserActivityListener(new UserActivityListener() {
|
||||
public void stateChanged() {
|
||||
//invoke after all other listeners
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@@ -133,7 +135,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
});
|
||||
}
|
||||
});
|
||||
myUserActivityWatcher.register(myOptionsPanel);
|
||||
userActivityWatcher.register(myOptionsPanel);
|
||||
updateSelectedProfileState();
|
||||
}
|
||||
|
||||
@@ -150,9 +152,11 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
|
||||
|
||||
private void wereToolSettingsModified() {
|
||||
for (Descriptor defaultDescriptor : myDescriptors.keySet()) {
|
||||
if (wereToolSettingsModified(defaultDescriptor)) return;
|
||||
for (Descriptor descriptor : myDescriptors.get(defaultDescriptor)) {
|
||||
for (Map.Entry<Descriptor, List<Descriptor>> entry : myDescriptors.entrySet()) {
|
||||
Descriptor desc = entry.getKey();
|
||||
if (wereToolSettingsModified(desc)) return;
|
||||
List<Descriptor> descriptors = entry.getValue();
|
||||
for (Descriptor descriptor : descriptors) {
|
||||
if (wereToolSettingsModified(descriptor)) return;
|
||||
}
|
||||
}
|
||||
@@ -161,27 +165,26 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
|
||||
private boolean wereToolSettingsModified(Descriptor descriptor) {
|
||||
InspectionProfileEntry tool = descriptor.getTool();
|
||||
if (tool != null) {
|
||||
if (mySelectedProfile.isToolEnabled(descriptor.getKey())) {
|
||||
Element oldConfig = descriptor.getConfig();
|
||||
@NonNls Element newConfig = new Element("options");
|
||||
try {
|
||||
tool.writeSettings(newConfig);
|
||||
if (tool == null || !mySelectedProfile.isToolEnabled(descriptor.getKey())) {
|
||||
return false;
|
||||
}
|
||||
Element oldConfig = descriptor.getConfig();
|
||||
@NonNls Element newConfig = new Element("options");
|
||||
try {
|
||||
tool.writeSettings(newConfig);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
if (!JDOMUtil.areElementsEqual(oldConfig, newConfig)) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
myTree.repaint();
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
if (!JDOMUtil.areElementsEqual(oldConfig, newConfig)) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
myTree.repaint();
|
||||
}
|
||||
}, 300);
|
||||
myModified = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
myModified = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -976,14 +979,15 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
|
||||
private boolean descriptorsAreChanged() {
|
||||
for (Descriptor defaultDescriptor : myDescriptors.keySet()) {
|
||||
if (mySelectedProfile.isToolEnabled(defaultDescriptor.getKey(), (NamedScope)null) != defaultDescriptor.isEnabled()){
|
||||
for (Map.Entry<Descriptor, List<Descriptor>> entry : myDescriptors.entrySet()) {
|
||||
Descriptor desc = entry.getKey();
|
||||
if (mySelectedProfile.isToolEnabled(desc.getKey(), (NamedScope)null) != desc.isEnabled()){
|
||||
return true;
|
||||
}
|
||||
if (mySelectedProfile.getErrorLevel(defaultDescriptor.getKey(), defaultDescriptor.getScope()) != defaultDescriptor.getLevel()) {
|
||||
if (mySelectedProfile.getErrorLevel(desc.getKey(), desc.getScope()) != desc.getLevel()) {
|
||||
return true;
|
||||
}
|
||||
final List<Descriptor> descriptors = myDescriptors.get(defaultDescriptor);
|
||||
final List<Descriptor> descriptors = entry.getValue();
|
||||
for (Descriptor descriptor : descriptors) {
|
||||
if (mySelectedProfile.isToolEnabled(descriptor.getKey(), descriptor.getScope()) != descriptor.isEnabled()) {
|
||||
return true;
|
||||
@@ -993,7 +997,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
final List<ScopeToolState> tools = mySelectedProfile.getNonDefaultTools(defaultDescriptor.getKey().toString());
|
||||
final List<ScopeToolState> tools = mySelectedProfile.getNonDefaultTools(desc.getKey().toString());
|
||||
if (tools.size() != descriptors.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class PsiDocumentManagerImpl extends PsiDocumentManager implements Projec
|
||||
}
|
||||
}
|
||||
|
||||
public void commitDocument(final Document doc) {
|
||||
public void commitDocument(@NotNull final Document doc) {
|
||||
final Document document = doc instanceof DocumentWindow ? ((DocumentWindow)doc).getDelegate() : doc;
|
||||
if (isUncommited(document)) {
|
||||
doCommit(document, null);
|
||||
@@ -459,11 +459,12 @@ public class PsiDocumentManagerImpl extends PsiDocumentManager implements Projec
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Document[] getUncommittedDocuments() {
|
||||
return myUncommittedDocuments.toArray(new Document[myUncommittedDocuments.size()]);
|
||||
}
|
||||
|
||||
public boolean isUncommited(Document document) {
|
||||
public boolean isUncommited(@NotNull Document document) {
|
||||
if(getSynchronizer().isInSynchronization(document)) return false;
|
||||
return ((DocumentEx)document).isInEventsHandling() || myUncommittedDocuments.contains(document);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
private static final Key<PsiFile> CACHED_PSI_FILE_COPY_IN_FILECONTENT = Key.create("CACHED_PSI_FILE_COPY_IN_FILECONTENT");
|
||||
|
||||
private final List<LanguageInjector> myLanguageInjectors = ContainerUtil.createEmptyCOWList();
|
||||
private final ProgressManager myProgressManager;
|
||||
|
||||
public PsiManagerImpl(Project project,
|
||||
final ProjectRootManagerEx projectRootManagerEx,
|
||||
@@ -144,7 +143,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
myResolveCache = new ResolveCache(this);
|
||||
|
||||
if (startupManager != null) {
|
||||
((StartupManagerEx)startupManager).registerPreStartupActivity(
|
||||
startupManager.registerPreStartupActivity(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
runPreStartupActivity();
|
||||
@@ -152,8 +151,6 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
myProgressManager = ProgressManager.getInstance();
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
@@ -226,7 +223,15 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
try {
|
||||
((FormatterImpl)FormatterEx.getInstance()).disableFormatting();
|
||||
component.disablePostprocessFormattingInside(new Computable<Object>() {
|
||||
public Object compute() { try { r.run(); } catch (Throwable t) { throwable[0] = t; } return null; }
|
||||
public Object compute() {
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throwable[0] = t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
|
||||
+7
-8
@@ -17,22 +17,19 @@ package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.components.ComponentConfig;
|
||||
import com.intellij.openapi.components.ComponentManager;
|
||||
import com.intellij.openapi.components.StateStorage;
|
||||
import com.intellij.openapi.components.ex.ComponentManagerEx;
|
||||
import com.intellij.openapi.components.impl.stores.IComponentStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.project.impl.ProjectMacrosUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -52,7 +49,9 @@ import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
|
||||
@@ -80,16 +80,18 @@ public class ConcurrencyUtil {
|
||||
* @return defaultValue if there is no entry in the map (in that case defaultValue is placed into the map), or corresponding value if entry already exists
|
||||
*/
|
||||
@NotNull
|
||||
public static <K,V> V cacheOrGet(ConcurrentMap<K, V> map, @NotNull final K key, @NotNull final V defaultValue) {
|
||||
public static <K,V> V cacheOrGet(@NotNull ConcurrentMap<K, V> map, @NotNull final K key, @NotNull final V defaultValue) {
|
||||
V prev = map.putIfAbsent(key, defaultValue);
|
||||
return prev == null ? defaultValue : prev;
|
||||
}
|
||||
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls final String threadFactoryName) {
|
||||
@NotNull
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NotNull @NonNls final String threadFactoryName) {
|
||||
return newSingleThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
|
||||
}
|
||||
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(final String threadFactoryName, final int threadPriority) {
|
||||
@NotNull
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NotNull final String threadFactoryName, final int threadPriority) {
|
||||
return new ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
|
||||
@@ -101,11 +103,13 @@ public class ConcurrencyUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls final String threadFactoryName) {
|
||||
@NotNull
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NotNull @NonNls final String threadFactoryName) {
|
||||
return newSingleScheduledThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
|
||||
}
|
||||
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(final String threadFactoryName, final int threadPriority) {
|
||||
@NotNull
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NotNull final String threadFactoryName, final int threadPriority) {
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
|
||||
public Thread newThread(final Runnable r) {
|
||||
final Thread thread = new Thread(r, threadFactoryName);
|
||||
|
||||
+3
-7
@@ -19,17 +19,12 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -41,14 +36,15 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import org.intellij.plugins.intelliLang.Configuration;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.intellij.plugins.intelliLang.Configuration;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class InjectLanguageAction implements IntentionAction {
|
||||
|
||||
Reference in New Issue
Block a user