diff options
Diffstat (limited to 'platform/core-impl')
12 files changed, 130 insertions, 115 deletions
diff --git a/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java index f82e7a80d5fb..cbb35b4f9812 100644 --- a/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java +++ b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java @@ -36,10 +36,7 @@ import com.intellij.openapi.extensions.ExtensionsArea; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.progress.*; -import com.intellij.openapi.util.ClassExtension; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.KeyedExtensionCollector; -import com.intellij.openapi.util.StaticGetter; +import com.intellij.openapi.util.*; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.openapi.vfs.encoding.EncodingRegistry; @@ -175,15 +172,7 @@ public class CoreApplicationEnvironment { ProgressIndicator progress, boolean failFastOnAcquireReadAction, @NotNull Processor<T> thingProcessor) { - final AsyncFutureResult<Boolean> asyncFutureResult = AsyncFutureFactory.getInstance().createAsyncFutureResult(); - try { - final boolean result = invokeConcurrentlyUnderProgress(things, progress, failFastOnAcquireReadAction, thingProcessor); - asyncFutureResult.set(result); - } - catch (Throwable t) { - asyncFutureResult.setException(t); - } - return asyncFutureResult; + return AsyncUtil.wrapBoolean(invokeConcurrentlyUnderProgress(things, progress, failFastOnAcquireReadAction, thingProcessor)); } @NotNull diff --git a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java index 72d290e61e25..939ab753574b 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java @@ -53,17 +53,17 @@ import java.util.*; * @author mike */ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { - private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginDescriptor"); - public static final IdeaPluginDescriptorImpl[] EMPTY_ARRAY = new IdeaPluginDescriptorImpl[0]; - private String myName; - private PluginId myId; + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginDescriptor"); + private static final StringInterner ourInterner = new WeakStringInterner(); private final NullableLazyValue<String> myDescription = new NullableLazyValue<String>() { @Override protected String compute() { return computeDescription(); } }; + private String myName; + private PluginId myId; private String myResourceBundleBaseName; private String myChangeNotes; private String myVersion; @@ -93,39 +93,62 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { private boolean myUseIdeaClassLoader; private boolean myUseCoreClassLoader; private boolean myEnabled = true; - private String mySinceBuild; private String myUntilBuild; - private Boolean mySkipped; - private List<String> myModules = null; public IdeaPluginDescriptorImpl(@NotNull File pluginPath) { myPath = pluginPath; } - IdeaPluginDescriptorImpl() { + @NotNull + public static String intern(@NotNull String s) { + return ourInterner.intern(s); } - public void setPath(@NotNull File path) { - myPath = path; + public static void internJDOMElement(@NotNull Element rootElement) { + JDOMUtil.internElement(rootElement, ourInterner); } - @Override - public File getPath() { - return myPath; + @Nullable + private static List<Element> copyElements(final Element[] elements) { + if (elements != null) { + List<Element> result = new ArrayList<Element>(); + for (Element extensionsRoot : elements) { + for (final Object o : extensionsRoot.getChildren()) { + Element element = (Element)o; + internJDOMElement(element); + result.add(element); + } + } + return result; + } + return null; } - private static final StringInterner ourInterner = new WeakStringInterner(); + @SuppressWarnings({"HardCodedStringLiteral"}) + private static String createDescriptionKey(final PluginId id) { + return "plugin." + id + ".description"; + } - @NotNull - public static String intern(@NotNull String s) { - return ourInterner.intern(s); + private static ComponentConfig[] mergeComponents(ComponentConfig[] first, ComponentConfig[] second) { + if (first == null) { + return second; + } + if (second == null) { + return first; + } + return ArrayUtil.mergeArrays(first, second); } - public static void internJDOMElement(@NotNull Element rootElement) { - JDOMUtil.internElement(rootElement, ourInterner); + @Override + public File getPath() { + return myPath; + } + + public void setPath(@NotNull File path) { + myPath = path; } public void readExternal(@NotNull Document document, @NotNull URL url) throws InvalidDataException, FileNotFoundException { @@ -243,7 +266,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myExtensions.putValue(ExtensionsAreaImpl.extractEPName(extension), extension); } } - + List<Element> extensionPoints = copyElements(pluginBean.extensionPoints); if (extensionPoints != null) { myExtensionsPoints = new MultiMap<String, Element>(); @@ -251,7 +274,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myExtensionsPoints.putValue(extensionPoint.getAttributeValue(ExtensionsAreaImpl.ATTRIBUTE_AREA), extensionPoint); } } - + myActionsElements = copyElements(pluginBean.actions); if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) { @@ -259,27 +282,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { } } - @Nullable - private static List<Element> copyElements(final Element[] elements) { - if (elements != null) { - List<Element> result = new ArrayList<Element>(); - for (Element extensionsRoot : elements) { - for (final Object o : extensionsRoot.getChildren()) { - Element element = (Element)o; - internJDOMElement(element); - result.add(element); - } - } - return result; - } - return null; - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - private static String createDescriptionKey(final PluginId id) { - return "plugin." + id + ".description"; - } - void registerExtensionPoints(ExtensionsArea area) { if (myExtensionsPoints != null) { for (Element element : myExtensionsPoints.get(area.getAreaClass())) { @@ -317,7 +319,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myDependencies; } - @Override @NotNull public PluginId[] getOptionalDependentPluginIds() { @@ -329,6 +330,11 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendor; } + public void setVendor( final String val ) + { + myVendor = val; + } + @Override public String getVersion() { return myVersion; @@ -344,6 +350,17 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myCategory; } + /* + This setter was explicitly defined to be able to set a category for a + descriptor outside its loading from the xml file. + Problem was that most commonly plugin authors do not publish the plugin's + category in its .xml file so to be consistent in plugins representation + (e.g. in the Plugins form) we have to set this value outside. + */ + public void setCategory( String category ){ + myCategory = category; + } + @SuppressWarnings("UnusedDeclaration") // Used in Upsource @Nullable public MultiMap<String, Element> getExtensionsPoints() { @@ -418,16 +435,31 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendorEmail; } + public void setVendorEmail( final String val ) + { + myVendorEmail = val; + } + @Override public String getVendorUrl() { return myVendorUrl; } + public void setVendorUrl( final String val ) + { + myVendorUrl = val; + } + @Override public String getUrl() { return url; } + public void setUrl( final String val ) + { + url = val; + } + @NonNls public String toString() { return "PluginDescriptor[name='" + myName + "', classpath='" + myPath + "']"; @@ -470,17 +502,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { } /* - This setter was explicitly defined to be able to set a category for a - descriptor outside its loading from the xml file. - Problem was that most commonly plugin authors do not publish the plugin's - category in its .xml file so to be consistent in plugins representation - (e.g. in the Plugins form) we have to set this value outside. - */ - public void setCategory( String category ){ - myCategory = category; - } - - /* This setter was explicitly defined to be able to set downloads count for a descriptor outside its loading from the xml file since this information is available only from the site. @@ -494,6 +515,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myDownloadCounter; } + public long getDate(){ + return myDate; + } + /* This setter was explicitly defined to be able to set date for a descriptor outside its loading from the xml file since this information @@ -503,27 +528,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myDate = date; } - public long getDate(){ - return myDate; - } - - public void setVendor( final String val ) - { - myVendor = val; - } - public void setVendorEmail( final String val ) - { - myVendorEmail = val; - } - public void setVendorUrl( final String val ) - { - myVendorUrl = val; - } - public void setUrl( final String val ) - { - url = val; - } - @Override public ClassLoader getPluginClassLoader() { return myLoader != null ? myLoader : getClass().getClassLoader(); @@ -534,6 +538,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendorLogoPath; } + public void setVendorLogoPath(final String vendorLogoPath) { + myVendorLogoPath = vendorLogoPath; + } + @Override public boolean getUseIdeaClassLoader() { return myUseIdeaClassLoader; @@ -547,10 +555,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myUseCoreClassLoader = useCoreClassLoader; } - public void setVendorLogoPath(final String vendorLogoPath) { - myVendorLogoPath = vendorLogoPath; - } - private String computeDescription() { ResourceBundle bundle = null; if (myResourceBundleBaseName != null) { @@ -635,16 +639,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myModuleComponents = mergeComponents(myModuleComponents, descriptor.myModuleComponents); } - private static ComponentConfig[] mergeComponents(ComponentConfig[] first, ComponentConfig[] second) { - if (first == null) { - return second; - } - if (second == null) { - return first; - } - return ArrayUtil.mergeArrays(first, second); - } - public Boolean getSkipped() { return mySkipped; } diff --git a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java index c026211c232a..8e047fe60b4d 100644 --- a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java +++ b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java @@ -20,6 +20,7 @@ import com.intellij.openapi.components.BaseComponent; import com.intellij.openapi.components.ComponentManager; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.util.containers.ConcurrentHashSet; @@ -137,6 +138,6 @@ public class MockComponentManager extends UserDataHolderBase implements Componen @NotNull @Override public Condition getDisposed() { - return Condition.FALSE; + return Conditions.alwaysFalse(); } } diff --git a/platform/core-impl/src/com/intellij/openapi/util/JDOMExternalizableAdapter.java b/platform/core-impl/src/com/intellij/openapi/util/JDOMExternalizableAdapter.java index 5248f4a0e535..8ba56e77f160 100644 --- a/platform/core-impl/src/com/intellij/openapi/util/JDOMExternalizableAdapter.java +++ b/platform/core-impl/src/com/intellij/openapi/util/JDOMExternalizableAdapter.java @@ -20,8 +20,10 @@ import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.diagnostic.Logger; import org.jdom.Element; +@Deprecated /** * @author Dmitry Avdeev + * @deprecated to remove in IDEA 14 */ public class JDOMExternalizableAdapter implements PersistentStateComponent<Element> { diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/HttpVirtualFile.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/HttpVirtualFile.java index 990418dc9c51..1e0f0bcd68b5 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/HttpVirtualFile.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/http/HttpVirtualFile.java @@ -16,10 +16,12 @@ package com.intellij.openapi.vfs.impl.http; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; /** * @author nik */ public abstract class HttpVirtualFile extends VirtualFile { + @Nullable public abstract RemoteFileInfo getFileInfo(); } diff --git a/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java index c6554f83fb7a..d8291fbd7f8d 100644 --- a/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java @@ -97,10 +97,11 @@ public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends Single @Override - public PsiFile getCachedPsi(Language target) { + public PsiFile getCachedPsi(@NotNull Language target) { return myRoots.get(target); } + @NotNull @Override public FileElement[] getKnownTreeRoots() { List<FileElement> files = new ArrayList<FileElement>(myRoots.size()); diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java index bed56c25292d..63a7f205c11c 100644 --- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java @@ -53,6 +53,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.util.Collections; import java.util.List; @@ -68,7 +69,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi private final boolean myPhysical; private final AtomicReference<PsiFile> myPsiFile = new AtomicReference<PsiFile>(); private volatile Content myContent; - private volatile SoftReference<Document> myDocument; + private volatile Reference<Document> myDocument; @NotNull private final Language myBaseLanguage; public SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile file) { @@ -213,10 +214,11 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi } - public PsiFile getCachedPsi(Language target) { + public PsiFile getCachedPsi(@NotNull Language target) { return myPsiFile.get(); } + @NotNull public FileElement[] getKnownTreeRoots() { PsiFile psiFile = myPsiFile.get(); if (psiFile == null || !(psiFile instanceof PsiFileImpl)) return new FileElement[0]; @@ -257,8 +259,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi protected boolean isIgnored() { final VirtualFile file = getVirtualFile(); - if (file instanceof LightVirtualFile) return false; - return FileTypeRegistry.getInstance().isFileIgnored(file); + return !(file instanceof LightVirtualFile) && FileTypeRegistry.getInstance().isFileIgnored(file); } @Nullable @@ -357,7 +358,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi Document document = com.intellij.reference.SoftReference.dereference(myDocument); if (document == null/* TODO[ik] make this change && isEventSystemEnabled()*/) { document = FileDocumentManager.getInstance().getDocument(getVirtualFile()); - myDocument = new SoftReference<Document>(document); + myDocument = document == null ? null : new SoftReference<Document>(document); } if (document != null && getContent() instanceof VirtualFileContent) { setContent(new DocumentContent()); @@ -446,16 +447,17 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi return null; } - public void forceCachedPsi(final PsiFile psiFile) { + public void forceCachedPsi(@NotNull PsiFile psiFile) { myPsiFile.set(psiFile); ((PsiManagerEx)myManager).getFileManager().setViewProvider(getVirtualFile(), this); } + @NotNull private Content getContent() { return myContent; } - private void setContent(final Content content) { + private void setContent(@NotNull Content content) { // temporarily commented //if (myPhysical) { // final Content oldContent = myContent; diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java index 6b2877d83351..e54b200507ca 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java @@ -527,6 +527,7 @@ public class FileManagerImpl implements FileManager { } void reloadFromDisk(@NotNull PsiFile file, boolean ignoreDocument) { + ApplicationManager.getApplication().assertWriteAccessAllowed(); VirtualFile vFile = file.getVirtualFile(); assert vFile != null; diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java index c73d0bd485ce..f8bfc611ce55 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java @@ -54,10 +54,10 @@ public class CompositeElement extends TreeElement { private TreeElement firstChild = null; private TreeElement lastChild = null; - private volatile int myModificationsCount = 0; + private volatile int myModificationsCount; private volatile int myCachedLength = -1; private volatile int myHC = -1; - private volatile PsiElement myWrapper = null; + private volatile PsiElement myWrapper; private static final boolean ASSERT_THREADING = true;//DebugUtil.CHECK || ApplicationManagerEx.getApplicationEx().isInternal() || ApplicationManagerEx.getApplicationEx().isUnitTestMode(); public CompositeElement(@NotNull IElementType type) { diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/FileElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/FileElement.java index 76d5c421094d..d3071ddbca7d 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/FileElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/FileElement.java @@ -70,7 +70,7 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge return psiElementCopy.getTreeElement(); } - public void setCharTable(CharTable table) { + public void setCharTable(@NotNull CharTable table) { myCharTable = table; } diff --git a/platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java b/platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java new file mode 100644 index 000000000000..49a3c5a0cc3c --- /dev/null +++ b/platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java @@ -0,0 +1,21 @@ +/* + * 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.refactoring.rename; + +public interface FragmentaryPsiReference extends BindablePsiReference { + boolean isReadOnlyFragment(); + boolean isFragmentOnlyRename(); +} diff --git a/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java b/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java index 9c05387f2137..e63589b40cb5 100644 --- a/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java +++ b/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.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. @@ -36,11 +36,13 @@ public class CachedValuesManagerImpl extends CachedValuesManager { myFactory = factory == null ? new DefaultCachedValuesFactory(project) : factory; } + @NotNull @Override public <T> CachedValue<T> createCachedValue(@NotNull CachedValueProvider<T> provider, boolean trackValue) { return myFactory.createCachedValue(provider, trackValue); } + @NotNull @Override public <T,P> ParameterizedCachedValue<T,P> createParameterizedCachedValue(@NotNull ParameterizedCachedValueProvider<T,P> provider, boolean trackValue) { return myFactory.createParameterizedCachedValue(provider, trackValue); |