Java 类org.eclipse.jdt.core.IProblemRequestor 实例源码

项目:che    文件:JavaModelManager.java   
public PerWorkingCopyInfo getPerWorkingCopyInfo(
    CompilationUnit workingCopy,
    boolean create,
    boolean recordUsage,
    IProblemRequestor problemRequestor) {
  synchronized (
      this.perWorkingCopyInfos) { // use the perWorkingCopyInfo collection as its own lock
    WorkingCopyOwner owner = workingCopy.owner;
    Map workingCopyToInfos = (Map) this.perWorkingCopyInfos.get(owner);
    if (workingCopyToInfos == null && create) {
      workingCopyToInfos = new HashMap();
      this.perWorkingCopyInfos.put(owner, workingCopyToInfos);
    }

    PerWorkingCopyInfo info =
        workingCopyToInfos == null
            ? null
            : (PerWorkingCopyInfo) workingCopyToInfos.get(workingCopy);
    if (info == null && create) {
      info = new PerWorkingCopyInfo(workingCopy, problemRequestor);
      workingCopyToInfos.put(workingCopy, info);
    }
    if (info != null && recordUsage) info.useCount++;
    return info;
  }
}
项目:che    文件:ReconcileWorkingCopyOperation.java   
/**
 * Report working copy problems to a given requestor.
 *
 * @param workingCopy
 * @param problemRequestor
 */
private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
  try {
    problemRequestor.beginReporting();
    for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext(); ) {
      CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
      if (categorizedProblems == null) continue;
      for (int i = 0, length = categorizedProblems.length; i < length; i++) {
        CategorizedProblem problem = categorizedProblems[i];
        if (JavaModelManager.VERBOSE) {
          System.out.println(
              "PROBLEM FOUND while reconciling : " + problem.getMessage()); // $NON-NLS-1$
        }
        if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break;
        problemRequestor.acceptProblem(problem);
      }
    }
  } finally {
    problemRequestor.endReporting();
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSpellingReconcileStrategy.java   
public void accept(SpellingProblem problem) {
    IProblemRequestor requestor= fRequestor;
    if (requestor != null) {
        try {
            int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
            String word= getDocument().get(problem.getOffset(), problem.getLength());
            boolean dictionaryMatch= false;
            boolean sentenceStart= false;
            if (problem instanceof JavaSpellingProblem) {
                dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch();
                sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart();
            }
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
            IEditorInput editorInput= fEditor.getEditorInput();
            if (editorInput != null) {
                CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
                requestor.acceptProblem(iProblem);
            }
        } catch (BadLocationException x) {
            // drop this SpellingProblem
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSpellingReconcileStrategy.java   
public void accept(SpellingProblem problem) {
    IProblemRequestor requestor= fRequestor;
    if (requestor != null) {
        try {
            int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
            String word= getDocument().get(problem.getOffset(), problem.getLength());
            boolean dictionaryMatch= false;
            boolean sentenceStart= false;
            if (problem instanceof JavaSpellingProblem) {
                dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch();
                sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart();
            }
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
            IEditorInput editorInput= fEditor.getEditorInput();
            if (editorInput != null) {
                CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
                requestor.acceptProblem(iProblem);
            }
        } catch (BadLocationException x) {
            // drop this SpellingProblem
        }
    }
}
项目:che    文件:QuickFixTest.java   
protected static final ArrayList collectCorrections2(ICompilationUnit cu, int nProblems)
    throws CoreException {

  final ArrayList problemsList = new ArrayList();
  final IProblemRequestor requestor =
      new IProblemRequestor() {
        public void acceptProblem(IProblem problem) {
          problemsList.add(problem);
        }

        public void beginReporting() {
          problemsList.clear();
        }

        public void endReporting() {}

        public boolean isActive() {
          return true;
        }
      };

  WorkingCopyOwner workingCopyOwner =
      new WorkingCopyOwner() {
        public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
          return requestor;
        }
      };
  ICompilationUnit wc = cu.getWorkingCopy(workingCopyOwner, null);
  try {
    wc.reconcile(ICompilationUnit.NO_AST, true, true, wc.getOwner(), null);
  } finally {
    wc.discardWorkingCopy();
  }

  IProblem[] problems = (IProblem[]) problemsList.toArray(new IProblem[problemsList.size()]);
  assertNumberOfProblems(nProblems, problems);

  return collectCorrections(cu, problems[0], null);
}
项目:che    文件:JavaModelManager.java   
public String toString() {
  StringBuffer buffer = new StringBuffer();
  buffer.append("Info for "); // $NON-NLS-1$
  buffer.append(((JavaElement) this.workingCopy).toStringWithAncestors());
  buffer.append("\nUse count = "); // $NON-NLS-1$
  buffer.append(this.useCount);
  buffer.append("\nProblem requestor:\n  "); // $NON-NLS-1$
  buffer.append(this.problemRequestor);
  if (this.problemRequestor == null) {
    IProblemRequestor requestor = getProblemRequestor();
    buffer.append("\nOwner problem requestor:\n  "); // $NON-NLS-1$
    buffer.append(requestor);
  }
  return buffer.toString();
}
项目:che    文件:JavaReconciler.java   
private WorkingCopyOwner createWorkingCopyOwner(ProblemRequestor problemRequestor) {
  return new WorkingCopyOwner() {
    public IProblemRequestor getProblemRequestor(ICompilationUnit unit) {
      return problemRequestor;
    }

    @Override
    public IBuffer createBuffer(ICompilationUnit workingCopy) {
      return new DocumentAdapter(workingCopy, (IFile) workingCopy.getResource());
    }
  };
}
项目:reflectify    文件:AbstractJavaModelTests.java   
public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner) throws JavaModelException {
    ICompilationUnit workingCopy = getCompilationUnit(path);
    if (owner != null)
        workingCopy = workingCopy.getWorkingCopy(owner, null/*no progress monitor*/);
    else
        workingCopy.becomeWorkingCopy(null/*no progress monitor*/);
    workingCopy.getBuffer().setContents(source);
    IProblemRequestor problemRequestor = owner.getProblemRequestor(workingCopy);
    if (problemRequestor instanceof ProblemRequestor) {
        ((ProblemRequestor) problemRequestor).initialize(source.toCharArray());
    }
    workingCopy.makeConsistent(null/*no progress monitor*/);
    return workingCopy;
}
项目:reflectify    文件:AbstractJavaModelTests.java   
/**
 * This method is still necessary when we need to use an owner and a specific problem requestor
 * (typically while using primary owner).
 * @deprecated
 */
public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner, IProblemRequestor problemRequestor) throws JavaModelException {
    ICompilationUnit workingCopy = getCompilationUnit(path);
    if (owner != null)
        workingCopy = workingCopy.getWorkingCopy(owner, problemRequestor, null/*no progress monitor*/);
    else
        workingCopy.becomeWorkingCopy(problemRequestor, null/*no progress monitor*/);
    workingCopy.getBuffer().setContents(source);
    if (problemRequestor instanceof ProblemRequestor)
        ((ProblemRequestor) problemRequestor).initialize(source.toCharArray());
    workingCopy.makeConsistent(null/*no progress monitor*/);
    return workingCopy;
}
项目:reflectify    文件:AbstractJavaModelTests.java   
protected ICompilationUnit newExternalWorkingCopy(String name, IClasspathEntry[] classpath, final IProblemRequestor problemRequestor, final String contents) throws JavaModelException {
    WorkingCopyOwner owner = new WorkingCopyOwner() {
        public IBuffer createBuffer(ICompilationUnit wc) {
            IBuffer buffer = super.createBuffer(wc);
            buffer.setContents(contents);
            return buffer;
        }
        public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
            return problemRequestor;
        }
    };
    return owner.newWorkingCopy(name, classpath, null/*no progress monitor*/);
}
项目:reflectify    文件:AbstractJavaModelTests.java   
/**
 * Create a new working copy owner using given problem requestor
 * to report problem.
 *
 * @param problemRequestor The requestor used to report problems
 * @return The created working copy owner
 */
protected WorkingCopyOwner newWorkingCopyOwner(final IProblemRequestor problemRequestor) {
    return new WorkingCopyOwner() {
        public IProblemRequestor getProblemRequestor(ICompilationUnit unit) {
            return problemRequestor;
        }
    };
}
项目:eclipse.jdt.ls    文件:LanguageServerWorkingCopyOwner.java   
@Override
public IProblemRequestor getProblemRequestor(ICompilationUnit cu) {
    return new DiagnosticsHandler(connection, cu);
}
项目:che    文件:JavaModelManager.java   
public PerWorkingCopyInfo(CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
  this.workingCopy = workingCopy;
  this.problemRequestor = problemRequestor;
}
项目:che    文件:JavaModelManager.java   
public void acceptProblem(IProblem problem) {
  IProblemRequestor requestor = getProblemRequestor();
  if (requestor == null) return;
  requestor.acceptProblem(problem);
}
项目:che    文件:JavaModelManager.java   
public void beginReporting() {
  IProblemRequestor requestor = getProblemRequestor();
  if (requestor == null) return;
  requestor.beginReporting();
}
项目:che    文件:JavaModelManager.java   
public void endReporting() {
  IProblemRequestor requestor = getProblemRequestor();
  if (requestor == null) return;
  requestor.endReporting();
}
项目:che    文件:JavaModelManager.java   
public IProblemRequestor getProblemRequestor() {
  if (this.problemRequestor == null && this.workingCopy.owner != null) {
    return this.workingCopy.owner.getProblemRequestor(this.workingCopy);
  }
  return this.problemRequestor;
}
项目:che    文件:JavaModelManager.java   
public boolean isActive() {
  IProblemRequestor requestor = getProblemRequestor();
  return requestor != null && requestor.isActive();
}
项目:che    文件:ReconcileWorkingCopyOperation.java   
/**
 * @throws org.eclipse.jdt.core.JavaModelException if setting the source of the original
 *     compilation unit fails
 */
protected void executeOperation() throws JavaModelException {
  checkCanceled();
  try {
    beginTask(Messages.element_reconciling, 2);

    CompilationUnit workingCopy = getWorkingCopy();
    boolean wasConsistent = workingCopy.isConsistent();

    // check is problem requestor is active
    IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo();
    if (problemRequestor != null)
      problemRequestor =
          ((JavaModelManager.PerWorkingCopyInfo) problemRequestor).getProblemRequestor();
    boolean defaultRequestorIsActive = problemRequestor != null && problemRequestor.isActive();
    IProblemRequestor ownerProblemRequestor =
        this.workingCopyOwner.getProblemRequestor(workingCopy);
    boolean ownerRequestorIsActive =
        ownerProblemRequestor != null
            && ownerProblemRequestor != problemRequestor
            && ownerProblemRequestor.isActive();
    this.requestorIsActive = defaultRequestorIsActive || ownerRequestorIsActive;

    // create the delta builder (this remembers the current content of the cu)
    this.deltaBuilder = new JavaElementDeltaBuilder(workingCopy);

    // make working copy consistent if needed and compute AST if needed
    makeConsistent(workingCopy);

    // notify reconcile participants only if working copy was not consistent or if forcing problem
    // detection
    // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=177319)
    if (!wasConsistent
        || ((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0)) {
      notifyParticipants(workingCopy);

      // recreate ast if one participant reset it
      if (this.ast == null) makeConsistent(workingCopy);
    }

    // report problems
    if (this.problems != null
        && (((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0)
            || !wasConsistent)) {
      if (defaultRequestorIsActive) {
        reportProblems(workingCopy, problemRequestor);
      }
      if (ownerRequestorIsActive) {
        reportProblems(workingCopy, ownerProblemRequestor);
      }
    }

    // report delta
    JavaElementDelta delta = this.deltaBuilder.delta;
    if (delta != null) {
      addReconcileDelta(workingCopy, delta);
    }
  } finally {
    done();
  }
}
项目:che    文件:BecomeWorkingCopyOperation.java   
public BecomeWorkingCopyOperation(
    CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
  super(new IJavaElement[] {workingCopy});
  this.problemRequestor = problemRequestor;
}
项目:PerformanceHat    文件:AbstractCompilationUnitDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public void becomeWorkingCopy(final IProblemRequestor problemRequestor, final IProgressMonitor monitor) throws JavaModelException {
  compilationUnit.becomeWorkingCopy(problemRequestor, monitor);
}
项目:PerformanceHat    文件:AbstractCompilationUnitDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public IJavaElement getSharedWorkingCopy(final IProgressMonitor monitor, final IBufferFactory factory, final IProblemRequestor problemRequestor) throws JavaModelException {
  return compilationUnit.getSharedWorkingCopy(monitor, factory, problemRequestor);
}
项目:PerformanceHat    文件:AbstractCompilationUnitDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public IJavaElement getWorkingCopy(final IProgressMonitor monitor, final IBufferFactory factory, final IProblemRequestor problemRequestor) throws JavaModelException {
  return compilationUnit.getWorkingCopy(monitor, factory, problemRequestor);
}
项目:PerformanceHat    文件:AbstractCompilationUnitDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public ICompilationUnit getWorkingCopy(final WorkingCopyOwner owner, final IProblemRequestor problemRequestor, final IProgressMonitor monitor) throws JavaModelException {
  return compilationUnit.getWorkingCopy(owner, problemRequestor, monitor);
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitDocumentProvider.java   
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
    ICompilationUnit original= null;
    if (element instanceof IFileEditorInput) {
        IFileEditorInput input= (IFileEditorInput) element;
        original= createCompilationUnit(input.getFile());
        if (original == null)
            return null;
    }

    FileInfo info= super.createFileInfo(element);
    if (!(info instanceof CompilationUnitInfo))
        return null;

    if (original == null)
        original= createFakeCompiltationUnit(element, false);
    if (original == null)
        return null;

    CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
    setUpSynchronization(cuInfo);

    IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
    if (requestor instanceof IProblemRequestorExtension) {
        IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
        extension.setIsActive(false);
        extension.setIsHandlingTemporaryProblems(isHandlingTemporaryProblems());
    }

    IResource resource= original.getResource();
    if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists()))
        original.becomeWorkingCopy(requestor, getProgressMonitor());
    cuInfo.fCopy= original;

    if (cuInfo.fModel instanceof CompilationUnitAnnotationModel)   {
        CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
        model.setCompilationUnit(cuInfo.fCopy);
    }

    if (cuInfo.fModel != null)
        cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);

    return cuInfo;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSpellingReconcileStrategy.java   
/**
 * Update the problem requester based on the current editor
 */
private void updateProblemRequester() {
    IAnnotationModel model= getAnnotationModel();
    fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompilationUnitDocumentProvider.java   
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
    ICompilationUnit original= null;
    if (element instanceof IFileEditorInput) {
        IFileEditorInput input= (IFileEditorInput) element;
        original= createCompilationUnit(input.getFile());
        if (original == null)
            return null;
    }

    FileInfo info= super.createFileInfo(element);
    if (!(info instanceof CompilationUnitInfo))
        return null;

    if (original == null)
        original= createFakeCompiltationUnit(element, false);
    if (original == null)
        return null;

    CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
    setUpSynchronization(cuInfo);

    IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
    if (requestor instanceof IProblemRequestorExtension) {
        IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
        extension.setIsActive(false);
        extension.setIsHandlingTemporaryProblems(isHandlingTemporaryProblems());
    }

    IResource resource= original.getResource();
    if (JavaModelUtil.isPrimary(original) && (resource == null || resource.exists()))
        original.becomeWorkingCopy(requestor, getProgressMonitor());
    cuInfo.fCopy= original;

    if (cuInfo.fModel instanceof CompilationUnitAnnotationModel)   {
        CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
        model.setCompilationUnit(cuInfo.fCopy);
    }

    if (cuInfo.fModel != null)
        cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);

    return cuInfo;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSpellingReconcileStrategy.java   
/**
 * Update the problem requester based on the current editor
 */
private void updateProblemRequester() {
    IAnnotationModel model= getAnnotationModel();
    fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
}