@Override protected void prepareOperation() throws CoreException, CommonException { if (inputLoc == null) { throw LangCore.createCoreException( "Could not determine filesystem path from editor input", null); } }
public static boolean runAndHandle( IRunnableContext runnableContext, IRunnableWithProgress op, boolean isCancellable, String errorTitle) { try { runnableContext.run(true, isCancellable, op); return true; } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (targetException instanceof OperationCanceledException) { return false; } CoreException ce; if (targetException instanceof CoreException) { ce = (CoreException) e.getTargetException(); } else { ce = LangCore.createCoreException("Internal error: ", targetException); } UIOperationExceptionHandler.handleOperationStatus(errorTitle, ce); return false; } catch (InterruptedException e) { return false; } }
public ExternalProcessResult runEngineTool( ProcessBuilder pb, String clientInput, ICancelMonitor cm) throws CoreException, OperationCancellation { try { return new RunEngineClientOperation(pb, cm).runProcess(clientInput); } catch (CommonException ce) { throw LangCore.createCoreException(ce); } }
@Override protected Indexable<ICompletionProposal> computeProposals( SourceOperationContext context, int offset, TimeoutProgressMonitor pm) throws CoreException, CommonException, OperationCancellation, OperationSoftFailure { IEditorPart editor = context.getEditor_nonNull(); Location fileLoc = context.getEditorInputLocation(); IDocument document = context.getDocument(); String prefix = lastWord(document, offset); GoUIPlugin.prepareGocodeManager_inUI(); IPath gocodePath = GocodeServerManager.getGocodePath(); if (gocodePath == null) { throw LangCore.createCoreException("Error: gocode path not provided.", null); } IProject project = getProjectFor(editor); GoEnvironment goEnvironment = GoProjectEnvironment.getGoEnvironment(project); // TODO: we should run this operation outside the UI thread. GocodeCompletionOperation client = new GocodeCompletionOperation( getEngineToolRunner(pm), goEnvironment, gocodePath.toOSString()); ExternalProcessResult processResult = client.execute(fileLoc.toPathString(), document.get(), offset); String stdout = processResult.getStdOutBytes().toString(StringUtil.UTF8); List<String> completions = new ArrayList2<>(GocodeCompletionOperation.LINE_SPLITTER.split(stdout)); ArrayList2<ICompletionProposal> results = new ArrayList2<>(); for (String completionEntry : completions) { handleResult(offset, /*codeContext,*/ results, prefix, completionEntry); } return results; }