当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionWorker.getPsiClass方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:VcsContentAnnotationExceptionFilter.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:VcsContentAnnotationExceptionFilter.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:41,代码来源:VcsContentAnnotationExceptionFilter.java

示例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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:76,代码来源:VcsContentAnnotationExceptionFilter.java

示例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());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:76,代码来源:VcsContentAnnotationExceptionFilter.java


注:本文中的com.intellij.execution.filters.ExceptionWorker.getPsiClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。