mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -807,6 +807,9 @@ public class JavaDocInfoGenerator {
|
||||
" background-color: #eeeeee;" +
|
||||
" margin-bottom: 10px;" +
|
||||
" }" +
|
||||
" p {" +
|
||||
" margin: 5px 0;" +
|
||||
" }" +
|
||||
" </style>" +
|
||||
"</head><body>");
|
||||
}
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.ILightStubFileElementType;
|
||||
import gnu.trove.TIntStack;
|
||||
|
||||
@@ -34,15 +35,23 @@ public class LightStubBuilder implements StubBuilder {
|
||||
|
||||
@Override
|
||||
public StubElement buildStubTree(final PsiFile file) {
|
||||
final FileASTNode node = file.getNode();
|
||||
assert node != null;
|
||||
|
||||
if (!(node.getElementType() instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + file);
|
||||
final FileType fileType = file.getFileType();
|
||||
if (!(fileType instanceof LanguageFileType)) {
|
||||
LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
final ILightStubFileElementType<?> type = (ILightStubFileElementType)node.getElementType();
|
||||
final Language language = ((LanguageFileType)fileType).getLanguage();
|
||||
final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
|
||||
if (!(contentType instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + contentType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
final FileASTNode node = file.getNode();
|
||||
assert node != null : file;
|
||||
|
||||
final ILightStubFileElementType<?> type = (ILightStubFileElementType)contentType;
|
||||
final LighterAST tree = new LighterAST(node.getCharTable(), type.parseContentsLight(node));
|
||||
final StubElement rootStub = createStubForFile(file, tree);
|
||||
buildStubTree(tree, tree.getRoot(), rootStub);
|
||||
|
||||
+7
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.hint.ElementLocationUtil;
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.ide.actions.ExternalJavaDocAction;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.lang.documentation.CompositeDocumentationProvider;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.lang.documentation.ExternalDocumentationHandler;
|
||||
@@ -132,6 +133,12 @@ public class DocumentationComponent extends JPanel implements Disposable {
|
||||
}
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
UISettings.setupAntialiasing(g);
|
||||
super.paintComponent(g);
|
||||
}
|
||||
};
|
||||
myText = "";
|
||||
myEditorPane.setEditable(false);
|
||||
|
||||
@@ -257,6 +257,11 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
return fileSizeIsGreaterThan(vFile, PersistentFS.MAX_INTELLISENSE_FILESIZE);
|
||||
}
|
||||
|
||||
public static boolean isTooLarge(final VirtualFile vFile, final long contentSize) {
|
||||
if (Boolean.TRUE.equals(vFile.getUserData(ourNoSizeLimitKey))) return false;
|
||||
return contentSize > PersistentFS.MAX_INTELLISENSE_FILESIZE;
|
||||
}
|
||||
|
||||
private static boolean fileSizeIsGreaterThan(final VirtualFile vFile, final long maxInBytes) {
|
||||
if (vFile instanceof LightVirtualFile) {
|
||||
// This is optimization in order to avoid conversion of [large] file contents to bytes
|
||||
|
||||
@@ -1163,7 +1163,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
final FileContent newFc = new FileContent(vFile, content.getText(), vFile.getCharset());
|
||||
final String contentText = content.getText();
|
||||
if (isTooLarge(vFile, contentText.length())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final FileContent newFc = new FileContent(vFile, contentText, vFile.getCharset());
|
||||
|
||||
if (dominantContentFile != null) {
|
||||
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
|
||||
@@ -1820,6 +1825,14 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTooLarge(VirtualFile file, long contentSize) {
|
||||
if (SingleRootFileViewProvider.isTooLarge(file, contentSize)) {
|
||||
final FileType type = FileTypeManager.getInstance().getFileTypeByFile(file);
|
||||
return !myNoLimitCheckTypes.contains(type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CollectingContentIterator createContentIterator() {
|
||||
return new UnindexedFilesFinder();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ public abstract class DumbService {
|
||||
*/
|
||||
public abstract boolean isDumb();
|
||||
|
||||
public static boolean isDumb(Project project) {
|
||||
return getInstance(project).isDumb();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the runnable when dumb mode ends
|
||||
* @param runnable runnable to run
|
||||
|
||||
@@ -225,7 +225,7 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon
|
||||
String _text = projectPath;
|
||||
final String projectName = getProjectName(projectPath);
|
||||
if (projectName != null) {
|
||||
_text = String.format("%s - %s", projectPath, projectName);
|
||||
_text = String.format("%s [%s]", projectPath, projectName);
|
||||
}
|
||||
|
||||
final Presentation presentation = getTemplatePresentation();
|
||||
|
||||
@@ -23,9 +23,16 @@ import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.Random;
|
||||
|
||||
public class RemoteServer {
|
||||
private static Remote ourRemote;
|
||||
private static Remote ourStub;
|
||||
|
||||
protected static void start(Remote remote) throws Exception {
|
||||
setupRMI();
|
||||
|
||||
if (ourRemote != null) throw new AssertionError("Already started");
|
||||
|
||||
ourRemote = remote;
|
||||
|
||||
Registry registry;
|
||||
int port = 0;
|
||||
for (Random random = new Random(); ;) {
|
||||
@@ -39,9 +46,9 @@ public class RemoteServer {
|
||||
}
|
||||
}
|
||||
try {
|
||||
final Remote stub = UnicastRemoteObject.exportObject(remote, 0);
|
||||
final String name = remote.getClass().getSimpleName() + Integer.toHexString(stub.hashCode());
|
||||
registry.bind(name, stub);
|
||||
ourStub = UnicastRemoteObject.exportObject(ourRemote, 0);
|
||||
final String name = remote.getClass().getSimpleName() + Integer.toHexString(ourStub.hashCode());
|
||||
registry.bind(name, ourStub);
|
||||
|
||||
System.out.println("Port/ID:" + port + "/" + name);
|
||||
Object lock = new Object();
|
||||
|
||||
@@ -358,6 +358,7 @@ public class PersistentEnumerator<Data> implements Forceable {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
markCorrupted();
|
||||
LOG.error(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.dom.impl;
|
||||
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
@@ -33,6 +34,7 @@ import org.jetbrains.idea.devkit.dom.IdeaPlugin;
|
||||
import org.jetbrains.idea.devkit.dom.PluginModule;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -66,6 +68,7 @@ public class IdeaPluginConverter extends ResolvingConverter<IdeaPlugin> {
|
||||
public static Collection<IdeaPlugin> collectAllVisiblePlugins(@NotNull XmlFile xmlFile) {
|
||||
|
||||
Project project = xmlFile.getProject();
|
||||
if (DumbService.isDumb(project)) return Collections.emptyList();
|
||||
GlobalSearchScope scope = GlobalSearchScope.allScope(project);
|
||||
List<DomFileElement<IdeaPlugin>> files = DomService.getInstance().getFileElements(IdeaPlugin.class, project, scope);
|
||||
return ContainerUtil.map(files, new Function<DomFileElement<IdeaPlugin>, IdeaPlugin>() {
|
||||
|
||||
+4
-4
@@ -26,8 +26,8 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceProvider;
|
||||
import com.intellij.psi.XmlElementFactory;
|
||||
import com.intellij.psi.impl.source.resolve.reference.PsiReferenceProviderBase;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.BasicAttributeValueReference;
|
||||
import com.intellij.psi.impl.source.xml.SchemaPrefix;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -44,7 +44,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* User: sweinreuter
|
||||
* Date: 24.07.2007
|
||||
*/
|
||||
public class PrefixReferenceProvider extends PsiReferenceProviderBase {
|
||||
public class PrefixReferenceProvider extends PsiReferenceProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.references.PrefixReferenceProvider");
|
||||
|
||||
@NotNull
|
||||
@@ -102,8 +102,8 @@ public class PrefixReferenceProvider extends PsiReferenceProviderBase {
|
||||
final String[] name = value.split(":");
|
||||
final XmlTag tag = factory.createTagFromText("<" + (name.length > 1 ? name[1] : value) + " />", XMLLanguage.INSTANCE);
|
||||
|
||||
QuickFixAction.registerQuickFixAction(info,
|
||||
new CreateNSDeclarationIntentionFix(tag, reference.getCanonicalText()));
|
||||
CreateNSDeclarationIntentionFix fix = CreateNSDeclarationIntentionFix.createFix(tag, reference.getCanonicalText());
|
||||
QuickFixAction.registerQuickFixAction(info, fix);
|
||||
} catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class XsltNamespaceContext implements NamespaceContext {
|
||||
|
||||
// TODO: verify API
|
||||
public MyCreateNSDeclarationAction(XmlElement xmlElement, String prefix, XmlFile xmlFile) {
|
||||
super(xmlElement, prefix);
|
||||
super(xmlElement, prefix, xmlFile);
|
||||
myXmlFile = xmlFile;
|
||||
}
|
||||
|
||||
|
||||
+14
-6
@@ -77,16 +77,24 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
|
||||
private final XmlFile myFile;
|
||||
private final XmlToken myToken;
|
||||
|
||||
public CreateNSDeclarationIntentionFix(@NotNull final PsiElement element,
|
||||
@NotNull final String namespacePrefix
|
||||
) {
|
||||
this(element, namespacePrefix, null);
|
||||
@Nullable
|
||||
public static CreateNSDeclarationIntentionFix createFix(@NotNull final PsiElement element, @NotNull final String namespacePrefix) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
return file instanceof XmlFile ? new CreateNSDeclarationIntentionFix(element, namespacePrefix, (XmlFile)file) : null;
|
||||
}
|
||||
|
||||
public CreateNSDeclarationIntentionFix(final PsiElement element, final String namespacePrefix, final XmlToken token) {
|
||||
protected CreateNSDeclarationIntentionFix(@NotNull final PsiElement element,
|
||||
@NotNull final String namespacePrefix, XmlFile containingFile) {
|
||||
this(element, namespacePrefix, null, containingFile);
|
||||
}
|
||||
|
||||
public CreateNSDeclarationIntentionFix(final PsiElement element,
|
||||
final String namespacePrefix,
|
||||
final XmlToken token,
|
||||
XmlFile containingFile) {
|
||||
myNamespacePrefix = namespacePrefix;
|
||||
myElement = element;
|
||||
myFile = (XmlFile)element.getContainingFile();
|
||||
myFile = containingFile;
|
||||
myToken = token;
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -127,7 +127,8 @@ public class XmlUnboundNsPrefixInspection extends XmlSuppressableInspectionTool
|
||||
final XmlTag tag = (XmlTag)element;
|
||||
if (!XmlUtil.JSP_URI.equals(tag.getNamespace())) {
|
||||
reportTagProblem(tag, localizedMessage, null, ProblemHighlightType.INFORMATION,
|
||||
isOnTheFly ? new CreateNSDeclarationIntentionFix(context, namespacePrefix, token):null,
|
||||
isOnTheFly ? new CreateNSDeclarationIntentionFix(context, namespacePrefix, token,
|
||||
(XmlFile)context.getContainingFile()):null,
|
||||
holder);
|
||||
}
|
||||
return;
|
||||
@@ -138,7 +139,8 @@ public class XmlUnboundNsPrefixInspection extends XmlSuppressableInspectionTool
|
||||
final HighlightInfoType infoType = extension.getHighlightInfoType(containingFile);
|
||||
final ProblemHighlightType highlightType = infoType == HighlightInfoType.ERROR ? ProblemHighlightType.ERROR : ProblemHighlightType.LIKE_UNKNOWN_SYMBOL;
|
||||
if (element instanceof XmlTag) {
|
||||
final CreateNSDeclarationIntentionFix fix = isOnTheFly ? new CreateNSDeclarationIntentionFix(context, namespacePrefix, token):null;
|
||||
final CreateNSDeclarationIntentionFix fix = isOnTheFly ? new CreateNSDeclarationIntentionFix(context, namespacePrefix, token,
|
||||
(XmlFile)context.getContainingFile()):null;
|
||||
reportTagProblem(element, localizedMessage, range, highlightType, fix, holder);
|
||||
} else {
|
||||
holder.registerProblem(element, localizedMessage, highlightType, range);
|
||||
|
||||
+3
-1
@@ -29,6 +29,7 @@ import com.intellij.psi.html.HtmlTag;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xml.XmlBundle;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.impl.schema.AnyXmlElementDescriptor;
|
||||
@@ -207,12 +208,13 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool {
|
||||
final String message = XmlErrorMessages.message("unknown.html.tag", name);
|
||||
|
||||
final PsiElement startTagName = XmlTagUtil.getStartTagNameElement(tag);
|
||||
assert startTagName != null;
|
||||
final PsiElement endTagName = XmlTagUtil.getEndTagNameElement(tag);
|
||||
|
||||
List<LocalQuickFix> quickfixes = new ArrayList<LocalQuickFix>();
|
||||
quickfixes.add(action);
|
||||
if (isOnTheFly) {
|
||||
quickfixes.add(new CreateNSDeclarationIntentionFix(startTagName, ""));
|
||||
ContainerUtil.addIfNotNull(CreateNSDeclarationIntentionFix.createFix(startTagName, ""), quickfixes);
|
||||
}
|
||||
if (HtmlUtil.isHtml5Tag(name) && !HtmlUtil.hasNonHtml5Doctype(tag)) {
|
||||
quickfixes.add(new SwitchToHtml5Action());
|
||||
|
||||
Reference in New Issue
Block a user