mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 262 B |
Binary file not shown.
|
After Width: | Height: | Size: 634 B |
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 276 B |
Binary file not shown.
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 4.4 KiB |
@@ -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.
|
||||
@@ -210,9 +210,14 @@ public final class LookupElementBuilder extends LookupElement {
|
||||
public LookupElementBuilder setTypeText(@Nullable String typeText, boolean grayed) {
|
||||
return withTypeText(typeText, grayed);
|
||||
}
|
||||
|
||||
public LookupElementBuilder withTypeText(@Nullable String typeText, boolean grayed) {
|
||||
return withTypeText(typeText, null, grayed);
|
||||
}
|
||||
|
||||
public LookupElementBuilder withTypeText(@Nullable String typeText, @Nullable Icon typeIcon, boolean grayed) {
|
||||
final LookupElementPresentation presentation = copyPresentation();
|
||||
presentation.setTypeText(typeText);
|
||||
presentation.setTypeText(typeText, typeIcon);
|
||||
presentation.setTypeGrayed(grayed);
|
||||
return new LookupElementBuilder(myLookupString, myObject, myInsertHandler, null, presentation,
|
||||
myAllLookupStrings, myCaseSensitive);
|
||||
|
||||
@@ -177,6 +177,7 @@ public class AllIcons {
|
||||
public static final Icon Atrule = IconLoader.getIcon("/css/atrule.png"); // 16x16
|
||||
public static final Icon Import = IconLoader.getIcon("/css/import.png"); // 16x16
|
||||
public static final Icon Property = IconLoader.getIcon("/css/property.png"); // 16x16
|
||||
public static final Icon Pseudo_class = IconLoader.getIcon("/css/pseudo-class.png"); // 16x16
|
||||
public static final Icon Pseudo_element = IconLoader.getIcon("/css/pseudo-element.png"); // 16x16
|
||||
public static final Icon Toolwindow = IconLoader.getIcon("/css/toolwindow.png"); // 13x13
|
||||
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.intellij.xml.util.documentation;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageDocumentation;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.lang.documentation.DocumentationUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
@@ -36,22 +39,19 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author maxim
|
||||
*/
|
||||
public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
private static DocumentationProvider ourStyleProvider;
|
||||
private DocumentationProvider myStyleProvider = null;
|
||||
private static DocumentationProvider ourScriptProvider;
|
||||
|
||||
@NonNls public static final String ELEMENT_ELEMENT_NAME = "element";
|
||||
@NonNls public static final String NBSP = ": ";
|
||||
@NonNls public static final String BR = "<br>";
|
||||
|
||||
public static void registerStyleDocumentationProvider(DocumentationProvider documentationProvider) {
|
||||
ourStyleProvider = documentationProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
|
||||
@@ -63,10 +63,10 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
|
||||
String result = getUrlForHtml(element, PsiTreeUtil.getParentOfType(originalElement,XmlTag.class,false));
|
||||
|
||||
if (result == null && ourStyleProvider !=null) {
|
||||
return ourStyleProvider.getUrlFor(element, originalElement);
|
||||
String result = getUrlForHtml(element, PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, false));
|
||||
DocumentationProvider styleProvider = getStyleProvider();
|
||||
if (result == null && styleProvider != null) {
|
||||
return styleProvider.getUrlFor(element, originalElement);
|
||||
}
|
||||
|
||||
return result != null ? Collections.singletonList(result) : null;
|
||||
@@ -126,7 +126,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
key = nameElement.getText();
|
||||
}
|
||||
|
||||
key = (key != null)?key.toLowerCase():"";
|
||||
key = StringUtil.notNullize(key).toLowerCase(Locale.US);
|
||||
|
||||
int dotIndex = key.indexOf('.');
|
||||
if (dotIndex > 0) {
|
||||
@@ -155,8 +155,9 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
final XmlTag tag = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, false);
|
||||
String result = generateDocForHtml(element, false, tag, originalElement);
|
||||
|
||||
if (result == null && ourStyleProvider !=null) {
|
||||
result = ourStyleProvider.generateDoc(element, originalElement);
|
||||
DocumentationProvider styleProvider = getStyleProvider();
|
||||
if (result == null && styleProvider !=null) {
|
||||
result = styleProvider.generateDoc(element, originalElement);
|
||||
}
|
||||
|
||||
if (result == null && ourScriptProvider !=null) {
|
||||
@@ -170,15 +171,11 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String generateDocForHtml(PsiElement element) {
|
||||
return generateDocForHtml(element,true, null, null);
|
||||
}
|
||||
|
||||
protected String generateDocForHtml(PsiElement element, boolean ommitHtmlSpecifics, XmlTag context, PsiElement originalElement) {
|
||||
protected String generateDocForHtml(PsiElement element, boolean omitHtmlSpecifics, XmlTag context, PsiElement originalElement) {
|
||||
final EntityDescriptor descriptor = findDocumentationDescriptor(element,context);
|
||||
|
||||
if (descriptor!=null) {
|
||||
return generateJavaDoc(descriptor, ommitHtmlSpecifics, originalElement);
|
||||
return generateJavaDoc(descriptor, omitHtmlSpecifics, originalElement);
|
||||
}
|
||||
if (element instanceof XmlEntityDecl) {
|
||||
final XmlEntityDecl entityDecl = (XmlEntityDecl)element;
|
||||
@@ -188,11 +185,11 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String generateJavaDoc(EntityDescriptor descriptor, boolean ommitHtmlSpecifics, PsiElement element) {
|
||||
private static String generateJavaDoc(EntityDescriptor descriptor, boolean omitHtmlSpecifics, PsiElement element) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
final boolean istag = descriptor instanceof HtmlTagDescriptor;
|
||||
final boolean isTag = descriptor instanceof HtmlTagDescriptor;
|
||||
|
||||
if (istag) {
|
||||
if (isTag) {
|
||||
DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.tag.name.message"),descriptor.getName(),buf);
|
||||
} else {
|
||||
DocumentationUtil.formatEntityName(XmlBundle.message("xml.javadoc.attribute.name.message"),descriptor.getName(),buf);
|
||||
@@ -200,10 +197,10 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
|
||||
buf.append(XmlBundle.message("xml.javadoc.description.message")).append(NBSP).append(descriptor.getDescription()).append(BR);
|
||||
|
||||
if (istag) {
|
||||
if (isTag) {
|
||||
final HtmlTagDescriptor tagDescriptor = (HtmlTagDescriptor)descriptor;
|
||||
|
||||
if (!ommitHtmlSpecifics) {
|
||||
if (!omitHtmlSpecifics) {
|
||||
boolean hasStartTag = tagDescriptor.isHasStartTag();
|
||||
if (!hasStartTag) {
|
||||
buf.append(XmlBundle.message("xml.javadoc.start.tag.could.be.omitted.message")).append(BR);
|
||||
@@ -227,7 +224,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
char dtdId = descriptor.getDtd();
|
||||
boolean deprecated = dtdId == EntityDescriptor.LOOSE_DTD;
|
||||
if (deprecated) {
|
||||
buf.append(XmlBundle.message("xml.javadoc.deprecated.message", deprecated)).append(BR);
|
||||
buf.append(XmlBundle.message("xml.javadoc.deprecated.message", true)).append(BR);
|
||||
}
|
||||
|
||||
if (dtdId == EntityDescriptor.LOOSE_DTD) {
|
||||
@@ -240,7 +237,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
buf.append(XmlBundle.message("xml.javadoc.defined.in.any.dtd.message"));
|
||||
}
|
||||
|
||||
if (!istag) {
|
||||
if (!isTag) {
|
||||
ColorSampleLookupValue.addColorPreviewAndCodeToLookup(element,buf);
|
||||
}
|
||||
|
||||
@@ -255,8 +252,9 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
|
||||
PsiElement result = createNavigationElementHTML(psiManager, object.toString(),element);
|
||||
|
||||
if (result== null && ourStyleProvider !=null) {
|
||||
result = ourStyleProvider.getDocumentationElementForLookupItem(psiManager, object, element);
|
||||
DocumentationProvider styleProvider = getStyleProvider();
|
||||
if (result== null && styleProvider !=null) {
|
||||
result = styleProvider.getDocumentationElementForLookupItem(psiManager, object, element);
|
||||
}
|
||||
if (result== null && ourScriptProvider !=null) {
|
||||
result = ourScriptProvider.getDocumentationElementForLookupItem(psiManager, object, element);
|
||||
@@ -271,8 +269,9 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
|
||||
PsiElement result = createNavigationElementHTML(psiManager, link, context);
|
||||
|
||||
if (result== null && ourStyleProvider !=null) {
|
||||
result = ourStyleProvider.getDocumentationElementForLink(psiManager, link,context);
|
||||
DocumentationProvider styleProvider = getStyleProvider();
|
||||
if (result== null && styleProvider !=null) {
|
||||
result = styleProvider.getDocumentationElementForLink(psiManager, link, context);
|
||||
}
|
||||
if (result== null && ourScriptProvider !=null) {
|
||||
result = ourScriptProvider.getDocumentationElementForLink(psiManager, link,context);
|
||||
@@ -281,7 +280,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
}
|
||||
|
||||
public PsiElement createNavigationElementHTML(PsiManager psiManager, String text, PsiElement context) {
|
||||
String key = text.toLowerCase();
|
||||
String key = text.toLowerCase(Locale.US);
|
||||
final HtmlTagDescriptor descriptor = HtmlDescriptorsTable.getTagDescriptor(key);
|
||||
|
||||
if (descriptor != null && !isAttributeContext(context) ) {
|
||||
@@ -332,4 +331,15 @@ public class HtmlDocumentationProvider implements DocumentationProvider {
|
||||
public static void registerScriptDocumentationProvider(final DocumentationProvider provider) {
|
||||
ourScriptProvider = provider;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private DocumentationProvider getStyleProvider() {
|
||||
if (myStyleProvider == null) {
|
||||
Language cssLanguage = Language.findLanguageByID("CSS");
|
||||
if (cssLanguage != null) {
|
||||
myStyleProvider = LanguageDocumentation.INSTANCE.forLanguage(cssLanguage);
|
||||
}
|
||||
}
|
||||
return myStyleProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.psi.xml.XmlText;
|
||||
public class XHtmlDocumentationProvider extends HtmlDocumentationProvider {
|
||||
|
||||
@Override
|
||||
protected String generateDocForHtml(PsiElement element, boolean ommitHtmlSpecifics, XmlTag context, PsiElement originalElement) {
|
||||
protected String generateDocForHtml(PsiElement element, boolean omitHtmlSpecifics, XmlTag context, PsiElement originalElement) {
|
||||
return super.generateDocForHtml(element, true, context, originalElement);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user