本文整理汇总了Java中com.intellij.execution.filters.ExceptionWorker.getPsiClass方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionWorker.getPsiClass方法的具体用法?Java ExceptionWorker.getPsiClass怎么用?Java ExceptionWorker.getPsiClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.filters.ExceptionWorker
的用法示例。
在下文中一共展示了ExceptionWorker.getPsiClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTextRangeForMethod
import com.intellij.execution.filters.ExceptionWorker; //导入方法依赖的package包/类
private static List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult) {
String method = worker.getMethod();
PsiClass psiClass = worker.getPsiClass();
PsiMethod[] methods;
if (method.contains("<init>")) {
// constructor
methods = psiClass.getConstructors();
} else if (method.contains("$")) {
// access$100
return null;
} else {
methods = psiClass.findMethodsByName(method, false);
}
if (methods.length > 0) {
if (methods.length == 1) {
final TextRange range = methods[0].getTextRange();
return Collections.singletonList(range);
} else {
List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
final List<TextRange> result = new ArrayList<TextRange>();
for (PsiMethod psiMethod : toIterate) {
result.add(psiMethod.getTextRange());
}
return result;
}
}
return null;
}
示例2: getTextRangeForMethod
import com.intellij.execution.filters.ExceptionWorker; //导入方法依赖的package包/类
private List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult) {
String method = worker.getMethod();
PsiClass psiClass = worker.getPsiClass();
PsiMethod[] methods;
if (method.contains("<init>")) {
// constructor
methods = psiClass.getConstructors();
} else if (method.contains("$")) {
// access$100
return null;
} else {
methods = psiClass.findMethodsByName(method, false);
}
if (methods.length > 0) {
if (methods.length == 1) {
final TextRange range = methods[0].getTextRange();
return Collections.singletonList(range);
} else {
List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
final List<TextRange> result = new ArrayList<TextRange>();
for (PsiMethod psiMethod : toIterate) {
result.add(psiMethod.getTextRange());
}
return result;
}
}
return null;
}
示例3: getTextRangeForMethod
import com.intellij.execution.filters.ExceptionWorker; //导入方法依赖的package包/类
private static List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult)
{
String method = worker.getMethod();
PsiClass psiClass = worker.getPsiClass();
PsiMethod[] methods;
if(method.contains("<init>"))
{
// constructor
methods = psiClass.getConstructors();
}
else if(method.contains("$"))
{
// access$100
return null;
}
else
{
methods = psiClass.findMethodsByName(method, false);
}
if(methods.length > 0)
{
if(methods.length == 1)
{
final TextRange range = methods[0].getTextRange();
return Collections.singletonList(range);
}
else
{
List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
final List<TextRange> result = new ArrayList<TextRange>();
for(PsiMethod psiMethod : toIterate)
{
result.add(psiMethod.getTextRange());
}
return result;
}
}
return null;
}
示例4: applyHeavyFilter
import com.intellij.execution.filters.ExceptionWorker; //导入方法依赖的package包/类
@Override
public void applyHeavyFilter(final Document copiedFragment,
int startOffset,
int startLineNumber,
Consumer<AdditionalHighlight> consumer) {
VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
Trinity<PsiClass, PsiFile, String> previousLineResult = null;
for (int i = 0; i < copiedFragment.getLineCount(); i++) {
final int lineStartOffset = copiedFragment.getLineStartOffset(i);
final int lineEndOffset = copiedFragment.getLineEndOffset(i);
final ExceptionWorker worker = new ExceptionWorker(myCache);
final String[] lineText = new String[1];
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
lineText[0] = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
worker.execute(lineText[0], lineEndOffset);
}
});
if (worker.getResult() != null) {
VirtualFile vf = worker.getFile().getVirtualFile();
if (vf.getFileSystem().isReadOnly()) continue;
VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf);
if (recentChangeRevision == null) {
recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf);
if (recentChangeRevision == null) {
myRevNumbersCache.put(vf, VcsRevisionNumber.NULL);
} else {
myRevNumbersCache.put(vf, recentChangeRevision);
}
}
if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) {
recentChangeRevision = null;
}
if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) ||
recentChangeRevision != null) {
final Document document = getDocumentForFile(worker);
if (document == null) return;
int startFileOffset = worker.getInfo().getThird().getStartOffset();
int idx = lineText[0].indexOf(':', startFileOffset);
int endIdx = idx == -1 ? worker.getInfo().getThird().getEndOffset() : idx;
consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + startFileOffset + 1, startOffset + lineStartOffset + endIdx));
if (worker.getPsiClass() != null) {
// also check method
final List<TextRange> ranges = findMethodRange(worker, document, previousLineResult);
if (ranges != null) {
boolean methodChanged = false;
for (TextRange range : ranges) {
if (localChangesCorrector.isRangeChangedLocally(vf, document, range)) {
methodChanged = true;
break;
}
final TextRange correctedRange = localChangesCorrector.getCorrectedRange(vf, document, range);
if (vcsContentAnnotation.intervalRecentlyChanged(vf, correctedRange, recentChangeRevision)) {
methodChanged = true;
break;
}
}
if (methodChanged) {
consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + worker.getInfo().getSecond().getStartOffset(),
startOffset + lineStartOffset + worker.getInfo().getSecond().getEndOffset()));
}
}
}
}
}
previousLineResult = worker.getResult() == null ? null :
new Trinity<PsiClass, PsiFile, String>(worker.getPsiClass(), worker.getFile(), worker.getMethod());
}
}
示例5: applyHeavyFilter
import com.intellij.execution.filters.ExceptionWorker; //导入方法依赖的package包/类
@Override
public void applyHeavyFilter(final Document copiedFragment,
int startOffset,
int startLineNumber,
Consumer<AdditionalHighlight> consumer) {
VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
Trinity<PsiClass, PsiFile, String> previousLineResult = null;
for (int i = 0; i < copiedFragment.getLineCount(); i++) {
final int lineStartOffset = copiedFragment.getLineStartOffset(i);
final int lineEndOffset = copiedFragment.getLineEndOffset(i);
final ExceptionWorker worker = new ExceptionWorker(myProject, myScope);
final String[] lineText = new String[1];
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
lineText[0] = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
worker.execute(lineText[0], lineEndOffset);
}
});
if (worker.getResult() != null) {
VirtualFile vf = worker.getFile().getVirtualFile();
if (vf.getFileSystem().isReadOnly()) continue;
VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf);
if (recentChangeRevision == null) {
recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf);
if (recentChangeRevision == null) {
myRevNumbersCache.put(vf, VcsRevisionNumber.NULL);
} else {
myRevNumbersCache.put(vf, recentChangeRevision);
}
}
if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) {
recentChangeRevision = null;
}
if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) ||
recentChangeRevision != null) {
final Document document = getDocumentForFile(worker);
if (document == null) return;
int startFileOffset = worker.getInfo().getThird().getStartOffset();
int idx = lineText[0].indexOf(':', startFileOffset);
int endIdx = idx == -1 ? worker.getInfo().getThird().getEndOffset() : idx;
consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + startFileOffset + 1, startOffset + lineStartOffset + endIdx));
if (worker.getPsiClass() != null) {
// also check method
final List<TextRange> ranges = findMethodRange(worker, document, previousLineResult);
if (ranges != null) {
boolean methodChanged = false;
for (TextRange range : ranges) {
if (localChangesCorrector.isRangeChangedLocally(vf, document, range)) {
methodChanged = true;
break;
}
final TextRange correctedRange = localChangesCorrector.getCorrectedRange(vf, document, range);
if (vcsContentAnnotation.intervalRecentlyChanged(vf, correctedRange, recentChangeRevision)) {
methodChanged = true;
break;
}
}
if (methodChanged) {
consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + worker.getInfo().getSecond().getStartOffset(),
startOffset + lineStartOffset + worker.getInfo().getSecond().getEndOffset()));
}
}
}
}
}
previousLineResult = worker.getResult() == null ? null :
new Trinity<PsiClass, PsiFile, String>(worker.getPsiClass(), worker.getFile(), worker.getMethod());
}
}