mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -49,6 +49,7 @@ public class BaseGenerateAction extends CodeInsightAction implements GenerateAct
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AnAction createEditTemplateAction(DataContext dataContext) {
|
||||
return null;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
|
||||
public abstract class InjectedLanguageManager {
|
||||
|
||||
/** @see com.intellij.lang.injection.MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME */
|
||||
/** @see MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME */
|
||||
@Deprecated
|
||||
public static final ExtensionPointName<MultiHostInjector> MULTIHOST_INJECTOR_EP_NAME = MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME;
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class InjectedLanguageManager {
|
||||
public abstract int injectedToHost(@NotNull PsiElement injectedContext, int injectedOffset);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.intellij.lang.injection.MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME extension point} for production and
|
||||
* @deprecated use {@link MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME extension point} for production and
|
||||
* {@link #registerMultiHostInjector(MultiHostInjector, Disposable)} for tests
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -66,7 +66,7 @@ public abstract class InjectedLanguageManager {
|
||||
public abstract void registerMultiHostInjector(@NotNull MultiHostInjector injector, @NotNull Disposable parentDisposable);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.intellij.lang.injection.MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME extension point} for production and
|
||||
* @deprecated use {@link MultiHostInjector#MULTIHOST_INJECTOR_EP_NAME extension point} for production and
|
||||
* {@link #registerMultiHostInjector(MultiHostInjector, Disposable)} for tests
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -22,16 +22,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Describes logic for injecting language inside hosting PSI element.
|
||||
* E.g. "inject XPath language into all XML attributes named 'select' that sit inside XML tag prefixed with 'xsl:'".
|
||||
* @see com.intellij.psi.PsiLanguageInjectionHost
|
||||
* @see PsiLanguageInjectionHost
|
||||
* @see com.intellij.lang.injection.MultiHostInjector
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LanguageInjector {
|
||||
ExtensionPointName<LanguageInjector> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.languageInjector");
|
||||
|
||||
/**
|
||||
* @param host PSI element inside which your language will be injected.
|
||||
* @param injectionPlacesRegistrar stores places where injection occurs. <br>
|
||||
* Call its {@link com.intellij.psi.InjectedLanguagePlaces#addPlace(com.intellij.lang.Language, com.intellij.openapi.util.TextRange, String, String)}
|
||||
* Call its {@link InjectedLanguagePlaces#addPlace(com.intellij.lang.Language, com.intellij.openapi.util.TextRange, String, String)}
|
||||
* method to register particular injection place.
|
||||
* For example, to inject your language in string literal inside quotes, you might want to <br>
|
||||
* {@code injectionPlacesRegistrar.addPlace(myLanguage, new TextRange(1,host.getTextLength()-1))}
|
||||
|
||||
+23
-26
@@ -45,10 +45,7 @@ import org.intellij.plugins.intelliLang.util.ContextComputationProcessor;
|
||||
import org.intellij.plugins.intelliLang.util.PsiUtilEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
@@ -69,6 +66,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement... operands) {
|
||||
if (operands.length == 0) return;
|
||||
boolean hasLiteral = false;
|
||||
@@ -107,10 +105,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
if (getAnnotatedElementsValue().contains(methodName)) {
|
||||
return true;
|
||||
}
|
||||
if (!annoOnly && getXmlAnnotatedElementsValue().contains(methodName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !annoOnly && getXmlAnnotatedElementsValue().contains(methodName);
|
||||
}
|
||||
};
|
||||
if (tempLanguage != null) {
|
||||
@@ -136,7 +131,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
private boolean myShouldStop;
|
||||
private boolean myUnparsable;
|
||||
|
||||
public InjectionProcessor(Configuration configuration, LanguageInjectionSupport support, PsiElement... operands) {
|
||||
InjectionProcessor(Configuration configuration, LanguageInjectionSupport support, PsiElement... operands) {
|
||||
myConfiguration = configuration;
|
||||
mySupport = support;
|
||||
myOperands = operands;
|
||||
@@ -147,10 +142,11 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
PsiElement topBlock = PsiUtil.getTopLevelEnclosingCodeBlock(firstOperand, null);
|
||||
LocalSearchScope searchScope = new LocalSearchScope(new PsiElement[]{topBlock instanceof PsiCodeBlock
|
||||
? topBlock : firstOperand.getContainingFile()}, "", true);
|
||||
THashSet<PsiModifierListOwner> visitedVars = new THashSet<>();
|
||||
ArrayList<PsiElement> places = new ArrayList<>(5);
|
||||
List<PsiElement> places = new ArrayList<>(5);
|
||||
places.add(firstOperand);
|
||||
Set<PsiModifierListOwner> visitedVars = new THashSet<>();
|
||||
class MyAnnoVisitor implements AnnotationUtilEx.AnnotatedElementVisitor {
|
||||
@Override
|
||||
public boolean visitMethodParameter(PsiExpression expression, PsiCall psiCallExpression) {
|
||||
PsiExpressionList list = psiCallExpression.getArgumentList();
|
||||
assert list != null;
|
||||
@@ -193,6 +189,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitMethodReturnStatement(PsiElement source, PsiMethod method) {
|
||||
if (areThereInjectionsWithName(method.getName(), false)) {
|
||||
process(method, method, -1);
|
||||
@@ -217,6 +214,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitVariable(PsiVariable variable) {
|
||||
visitVariableUsages(variable);
|
||||
PsiElement anchor = !(variable.getFirstChild() instanceof PsiComment) ? variable :
|
||||
@@ -232,6 +230,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitAnnotationParameter(PsiNameValuePair nameValuePair, PsiAnnotation psiAnnotation) {
|
||||
String paramName = nameValuePair.getName();
|
||||
String methodName = paramName != null ? paramName : PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME;
|
||||
@@ -245,6 +244,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitReference(PsiReferenceExpression expression) {
|
||||
if (myConfiguration.getAdvancedConfiguration().getDfaOption() == Configuration.DfaOption.OFF) return true;
|
||||
PsiElement e = expression.resolve();
|
||||
@@ -276,7 +276,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
MyAnnoVisitor visitor = new MyAnnoVisitor();
|
||||
if (!visitor.processCommentInjection(firstOperand)) {
|
||||
return;
|
||||
@@ -335,10 +335,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
|
||||
protected boolean processXmlInjections(BaseInjection injection, PsiModifierListOwner owner, PsiMethod method, int paramIndex) {
|
||||
processInjectionWithContext(injection, true);
|
||||
if (injection.isTerminal()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !injection.isTerminal();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -377,24 +374,24 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
unparsableRef.set(Boolean.TRUE);
|
||||
}
|
||||
else {
|
||||
if (!(curHost instanceof PsiLiteralExpression)) {
|
||||
TextRange textRange = ElementManipulators.getManipulator(curHost).getRangeInElement(curHost);
|
||||
TextRange.assertProperRange(textRange, injection);
|
||||
result.add(Trinity.create(curHost, InjectedLanguage.create(injection.getInjectedLanguageId(), curPrefix, curSuffix, true),
|
||||
textRange));
|
||||
}
|
||||
else {
|
||||
if (curHost instanceof PsiLiteralExpression) {
|
||||
List<TextRange> injectedArea = injection.getInjectedArea(curHost);
|
||||
for (int j = 0, injectedAreaSize = injectedArea.size(); j < injectedAreaSize; j++) {
|
||||
TextRange textRange = injectedArea.get(j);
|
||||
TextRange.assertProperRange(textRange, injection);
|
||||
result.add(Trinity.create(
|
||||
curHost, InjectedLanguage.create(injection.getInjectedLanguageId(),
|
||||
(separateFiles || j == 0 ? curPrefix : ""),
|
||||
(separateFiles || j == injectedAreaSize - 1 ? curSuffix : ""),
|
||||
separateFiles || j == 0 ? curPrefix : "",
|
||||
separateFiles || j == injectedAreaSize - 1 ? curSuffix : "",
|
||||
true), textRange));
|
||||
}
|
||||
}
|
||||
else {
|
||||
TextRange textRange = ElementManipulators.getManipulator(curHost).getRangeInElement(curHost);
|
||||
TextRange.assertProperRange(textRange, injection);
|
||||
result.add(Trinity.create(curHost, InjectedLanguage.create(injection.getInjectedLanguageId(), curPrefix, curSuffix, true),
|
||||
textRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
@@ -442,7 +439,7 @@ public class ConcatenationInjector implements ConcatenationAwareInjector {
|
||||
}
|
||||
|
||||
|
||||
public Collection<String> getAnnotatedElementsValue() {
|
||||
private Collection<String> getAnnotatedElementsValue() {
|
||||
// note: external annotations not supported
|
||||
return InjectionCache.getInstance(myProject).getAnnoIndex();
|
||||
}
|
||||
|
||||
+2
@@ -47,11 +47,13 @@ public class CommentLanguageInjector implements MultiHostInjector {
|
||||
mySupports = ArrayUtil.toObjectArray(supports, LanguageInjectionSupport.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Collections.singletonList(PsiLanguageInjectionHost.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
|
||||
if (!(context instanceof PsiLanguageInjectionHost) || context instanceof PsiComment) return;
|
||||
if (!((PsiLanguageInjectionHost)context).isValidHost()) return;
|
||||
|
||||
+2
@@ -38,11 +38,13 @@ public final class DefaultLanguageInjector implements MultiHostInjector {
|
||||
mySupports = ArrayUtil.toObjectArray(InjectorUtils.getActiveInjectionSupports(), LanguageInjectionSupport.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Collections.singletonList(PsiLanguageInjectionHost.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
|
||||
if (!(context instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost)context).isValidHost()) return;
|
||||
PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
|
||||
|
||||
+6
-3
@@ -27,8 +27,11 @@ public final class InjectedLanguage {
|
||||
private static Map<String, Language> ourLanguageCache;
|
||||
private static int ourLanguageCount;
|
||||
|
||||
@NotNull
|
||||
private final String myID;
|
||||
@NotNull
|
||||
private final String myPrefix;
|
||||
@NotNull
|
||||
private final String mySuffix;
|
||||
private final boolean myDynamic;
|
||||
|
||||
@@ -68,7 +71,7 @@ public final class InjectedLanguage {
|
||||
|
||||
@Nullable
|
||||
public static Language findLanguageById(@Nullable String langID) {
|
||||
if (langID == null || langID.length() == 0) {
|
||||
if (langID == null || langID.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
synchronized (InjectedLanguage.class) {
|
||||
@@ -123,11 +126,11 @@ public final class InjectedLanguage {
|
||||
|
||||
final InjectedLanguage that = (InjectedLanguage)o;
|
||||
|
||||
return !(myID != null ? !myID.equals(that.myID) : that.myID != null);
|
||||
return myID.equals(that.myID);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (myID != null ? myID.hashCode() : 0);
|
||||
return myID.hashCode();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
@@ -41,11 +41,13 @@ public class TemporaryPlacesInjector implements MultiHostInjector {
|
||||
myRegistry = registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Collections.singletonList(PsiLanguageInjectionHost.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
|
||||
if (!(context instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost)context).isValidHost()) return;
|
||||
PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
|
||||
|
||||
+2
@@ -67,11 +67,13 @@ public final class XmlLanguageInjector implements MultiHostInjector {
|
||||
mySupport = InjectorUtils.findNotNullInjectionSupport(XmlLanguageInjectionSupport.XML_SUPPORT_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Arrays.asList(XmlTag.class, XmlAttributeValue.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull PsiElement host) {
|
||||
final XmlElement xmlElement = (XmlElement) host;
|
||||
if (!isInIndex(xmlElement)) return;
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.util.List;
|
||||
* Date: Apr 9, 2010
|
||||
*/
|
||||
class AntReferenceInjector implements DomReferenceInjector {
|
||||
@Override
|
||||
public String resolveString(@Nullable String unresolvedText, @NotNull ConvertContext context) {
|
||||
// todo: speed optimization: disable string resolution in places where it is not applicable
|
||||
if (unresolvedText == null) {
|
||||
@@ -48,6 +49,7 @@ class AntReferenceInjector implements DomReferenceInjector {
|
||||
return AntStringResolver.computeString(element, unresolvedText);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] inject(@Nullable String unresolvedText, @NotNull PsiElement element, @NotNull ConvertContext context) {
|
||||
if (element instanceof XmlAttributeValue) {
|
||||
|
||||
@@ -21,6 +21,7 @@ public class ScriptLanguageInjector implements MultiHostInjector {
|
||||
private static final XmlElementPattern.XmlTextPattern SCRIPT_PATTERN = XmlPatterns.xmlText().withParent(
|
||||
XmlPatterns.xmlTag().withName(FxmlConstants.FX_SCRIPT));
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement host) {
|
||||
if (SCRIPT_PATTERN.accepts(host)) {
|
||||
final List<String> registeredLanguages = JavaFxPsiUtil.parseInjectedLanguages((XmlFile)host.getContainingFile());
|
||||
@@ -38,6 +39,7 @@ public class ScriptLanguageInjector implements MultiHostInjector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Collections.singletonList(XmlText.class);
|
||||
|
||||
+2
@@ -27,12 +27,14 @@ import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
|
||||
|
||||
public class MavenPropertyPsiReferenceInjector implements DomReferenceInjector {
|
||||
@Override
|
||||
public String resolveString(@Nullable String unresolvedText, @NotNull ConvertContext context) {
|
||||
if (StringUtil.isEmptyOrSpaces(unresolvedText)) return unresolvedText;
|
||||
MavenDomProjectModel model = (MavenDomProjectModel)DomUtil.getFileElement(context.getInvocationElement()).getRootElement();
|
||||
return MavenPropertyResolver.resolve(unresolvedText, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] inject(@Nullable String unresolvedText, @NotNull PsiElement element, @NotNull ConvertContext context) {
|
||||
return MavenPropertyPsiReferenceProvider.getReferences(element, true);
|
||||
|
||||
+5
@@ -35,22 +35,27 @@ public class PropertiesCommenter implements CodeDocumentationAwareCommenter, Sel
|
||||
public static final String HASH_COMMENT_PREFIX = "#";
|
||||
public static final String EXCLAMATION_COMMENT_PREFIX = "!";
|
||||
|
||||
@Override
|
||||
public String getLineCommentPrefix() {
|
||||
return HASH_COMMENT_PREFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
@@ -127,11 +127,13 @@ public class XPathLanguageInjector implements MultiHostInjector {
|
||||
return ranges;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
|
||||
return Arrays.asList(XmlAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
|
||||
final XmlAttribute attribute = (XmlAttribute)context;
|
||||
if (!XsltSupport.isXPathAttribute(attribute)) return;
|
||||
|
||||
@@ -10,24 +10,29 @@ public class YAMLCommenter implements Commenter {
|
||||
@NonNls
|
||||
private static final String LINE_COMMENT_PREFIX = "#";
|
||||
|
||||
@Override
|
||||
public String getLineCommentPrefix() {
|
||||
return LINE_COMMENT_PREFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentPrefix() {
|
||||
// N/A
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentSuffix() {
|
||||
// N/A
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,22 +25,27 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author yole
|
||||
*/
|
||||
public class PythonCommenter implements CodeDocumentationAwareCommenter, IndentedCommenter {
|
||||
@Override
|
||||
public String getLineCommentPrefix() {
|
||||
return "# ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentedBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user