mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-74341 LiveTemplates: templates with 'Other' context are available in the 'HTML Text' context
This commit is contained in:
@@ -129,6 +129,10 @@ public abstract class JavaCodeContextType extends TemplateContextType {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (psiElement().withParents(PsiTypeElement.class, PsiClass.class).accepts(parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessingContext context = new ProcessingContext();
|
||||
if (psiElement().inside(PsiExpression.class).afterLeaf(psiElement().inside(psiElement(PsiExpression.class).save("prevExpr"))).accepts(element, context)) {
|
||||
PsiExpression prevExpr = (PsiExpression)context.get("prevExpr");
|
||||
|
||||
+10
-1
@@ -430,6 +430,15 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<TemplateContextType> getBases(TemplateContextType type) {
|
||||
ArrayList<TemplateContextType> list = new ArrayList<TemplateContextType>();
|
||||
while (true) {
|
||||
type = type.getBaseContextType();
|
||||
if (type == null) return list;
|
||||
list.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<TemplateContextType> getDirectlyApplicableContextTypes(@Nullable PsiFile file, int offset, @Nullable FileType fileType) {
|
||||
LinkedHashSet<TemplateContextType> set = new LinkedHashSet<TemplateContextType>();
|
||||
LinkedList<TemplateContextType> contexts = buildOrderedContextTypes();
|
||||
@@ -442,7 +451,7 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
|
||||
removeBases:
|
||||
while (true) {
|
||||
for (TemplateContextType type : set) {
|
||||
if (set.remove(type.getBaseContextType())) {
|
||||
if (set.removeAll(getBases(type))) {
|
||||
continue removeBases;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user