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:
@@ -17,7 +17,6 @@ package com.intellij.codeInsight.template.macro;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -32,14 +31,9 @@ public class ClassNameMacro extends Macro {
|
||||
}
|
||||
|
||||
public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) {
|
||||
Project project = context.getProject();
|
||||
int templateStartOffset = context.getTemplateStartOffset();
|
||||
int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement place = file.findElementAt(offset);
|
||||
PsiElement place = context.getPsiElementAtStartOffset();
|
||||
PsiClass aClass = null;
|
||||
|
||||
while(place != null){
|
||||
|
||||
@@ -18,8 +18,10 @@ package com.intellij.codeInsight.template.macro;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.lang.LangBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiClassInitializer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MethodNameMacro extends Macro {
|
||||
@@ -38,14 +40,7 @@ public class MethodNameMacro extends Macro {
|
||||
}
|
||||
|
||||
public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) {
|
||||
Project project = context.getProject();
|
||||
int templateStartOffset = context.getTemplateStartOffset();
|
||||
final int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement place = file.findElementAt(offset);
|
||||
PsiElement place = context.getPsiElementAtStartOffset();
|
||||
while(place != null){
|
||||
if (place instanceof PsiMethod){
|
||||
return new TextResult(((PsiMethod)place).getName());
|
||||
|
||||
+4
-10
@@ -17,8 +17,9 @@ package com.intellij.codeInsight.template.macro;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -40,14 +41,7 @@ public class MethodParametersMacro extends Macro {
|
||||
}
|
||||
|
||||
public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) {
|
||||
Project project = context.getProject();
|
||||
int templateStartOffset = context.getTemplateStartOffset();
|
||||
final int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement place = file.findElementAt(offset);
|
||||
PsiElement place = context.getPsiElementAtStartOffset();
|
||||
while(place != null){
|
||||
if (place instanceof PsiMethod){
|
||||
List<Result> result = new ArrayList<Result>();
|
||||
|
||||
+1
-11
@@ -16,10 +16,7 @@
|
||||
package com.intellij.codeInsight.template.macro;
|
||||
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -41,14 +38,7 @@ public class MethodReturnTypeMacro extends Macro {
|
||||
}
|
||||
|
||||
public Result calculateResult(@NotNull final Expression[] params, final ExpressionContext context) {
|
||||
Project project = context.getProject();
|
||||
int templateStartOffset = context.getTemplateStartOffset();
|
||||
final int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement place = file.findElementAt(offset);
|
||||
PsiElement place = context.getPsiElementAtStartOffset();
|
||||
while(place != null){
|
||||
if (place instanceof PsiMethod){
|
||||
return new PsiTypeResult(((PsiMethod)place).getReturnType(), place.getProject());
|
||||
|
||||
+5
-10
@@ -17,8 +17,10 @@ package com.intellij.codeInsight.template.macro;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiAnonymousClass;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiTypeParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class QualifiedClassNameMacro extends Macro {
|
||||
@@ -32,14 +34,7 @@ public class QualifiedClassNameMacro extends Macro {
|
||||
}
|
||||
|
||||
public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) {
|
||||
Project project = context.getProject();
|
||||
int templateStartOffset = context.getTemplateStartOffset();
|
||||
final int offset = templateStartOffset > 0 ? context.getTemplateStartOffset() - 1 : context.getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
|
||||
PsiElement place = file.findElementAt(offset);
|
||||
PsiElement place = context.getPsiElementAtStartOffset();
|
||||
while(place != null){
|
||||
if (place instanceof PsiClass && !(place instanceof PsiAnonymousClass) && !(place instanceof PsiTypeParameter)){
|
||||
final PsiClass psiClass = ((PsiClass)place);
|
||||
|
||||
@@ -19,7 +19,9 @@ package com.intellij.codeInsight.template;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ExpressionContext {
|
||||
@NonNls Key<String> SELECTION = Key.create("SELECTION");
|
||||
@@ -30,5 +32,7 @@ public interface ExpressionContext {
|
||||
int getTemplateStartOffset();
|
||||
int getTemplateEndOffset();
|
||||
<T> T getProperty(Key<T> key);
|
||||
@Nullable
|
||||
PsiElement getPsiElementAtStartOffset();
|
||||
}
|
||||
|
||||
|
||||
@@ -793,6 +793,19 @@ public class TemplateState implements Disposable {
|
||||
public <T> T getProperty(Key<T> key) {
|
||||
return (T)myProperties.get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement getPsiElementAtStartOffset() {
|
||||
Project project = getProject();
|
||||
int templateStartOffset = getTemplateStartOffset();
|
||||
int offset = templateStartOffset > 0 ? getTemplateStartOffset() - 1 : getTemplateStartOffset();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(getEditor().getDocument());
|
||||
return file == null ? null : file.findElementAt(offset);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TextSplitter extends BaseSplitter {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile("([&#]|0x[0-9]*)?\\p{L}+'?\\p{L}(_*\\p{L})*");
|
||||
private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile("([&#]|0x[0-9]*)?\\p{L}+'?\\p{L}[_\\p{L}]*");
|
||||
|
||||
@Override
|
||||
public void split(@Nullable String text, @NotNull TextRange range, Consumer<TextRange> consumer) {
|
||||
|
||||
Reference in New Issue
Block a user