📄 dispatch.java
字号:
ci ++; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_MULTIPLE_COMPLETION_LINE); i = parseXmlTagHandleMessages(ss, i, len,data); } cd.lns[ci] = new CompletionDialog3.LineData(cd.completions.bufi, -1, ""); protocolCheckEq(currentTag, "/"+Protocol.PPC_FULL_MULTIPLE_COMPLETIONS); CompletionDialog3.showCompletionDialog(); return(i); } public static int dispatchAllCompletionsList(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { XrefCharBuffer completions = new XrefCharBuffer(); completions.append(ss, i, attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_ALL_COMPLETIONS); CompletionDialog.showCompletionDialog(completions.toString(), data, attrNoFocus); return(i); } public static int dispatchSymbolList(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { XrefCharBuffer symbols = new XrefCharBuffer(); i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_STRING_VALUE)) { symbols.append(ss, i, attrLen); symbols.append("\n"); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); } protocolCheckEq(currentTag, "/"+Protocol.PPC_SYMBOL_LIST); data.symbolList = symbols; return(i); } /* TODO, delete this method, it is useless since 1.6.0 */ public static int dispatchSetProject(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { data.info = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_SET_PROJECT); return(i); } public static int dispatchSetInfo(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { data.info = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_SET_INFO); return(i); } public static int dispatchNoProject(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { int rr; String file = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); if (data.projectCreationAllowed) { protocolCheckEq(currentTag, "/"+Protocol.PPC_NO_PROJECT); rr = JOptionPane.showConfirmDialog(s.getProbableParent(data.callerComponent), "No project for file "+file+".\nCreate new project?" , "No Project", JOptionPane.YES_NO_OPTION); if (rr==JOptionPane.YES_OPTION) { OptionsForProjectsDialog od = new OptionsForProjectsDialog(s.view, true); } } throw new XrefAbortException(); } public static int dispatchNoSymbol(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { // handle no symbol by pushing symbol by name String name = s.getIdentifierOnCaret(); i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_NO_SYMBOL); new Push(new String[] {"-olcxpushname="+name, "-olnodialog"}, data); return(i); } public static int dispatchAvailableRefactorings(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { boolean firstFlag = true; Refactorings refactors[] = new Refactorings[Protocol.PPC_MAX_AVAILABLE_REFACTORINGS]; int refactoringsi = 0; i = parseXmlTagHandleMessages(ss, i, len,data); while (currentTag.equals(Protocol.PPC_INT_VALUE)) { Refactorings rrr = Refactorings.getRefactoringFromCode(attrVal); if (rrr!=null) { s.assertt(refactoringsi < Protocol.PPC_MAX_AVAILABLE_REFACTORINGS); refactors[refactoringsi] = rrr; refactors[refactoringsi].param = ss.substring(i, i+attrLen); refactoringsi++; } i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_INT_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); } protocolCheckEq(currentTag, "/"+Protocol.PPC_AVAILABLE_REFACTORINGS); Refactorings[] refactorings = new Refactorings[refactoringsi]; System.arraycopy(refactors, 0, refactorings, 0, refactoringsi); new RefactoringDialog(refactorings); return(i); } public static int dispatchCopyBlock(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { int cc = s.getCaretPosition(); block = s.getBuffer().getText(cc, cc+attrVal); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_REFACTORING_COPY_BLOCK); return(i); } public static int dispatchCutBlock(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { Buffer buffer = s.getBuffer(); int blen = buffer.getLength(); int caret = s.getCaretPosition(); // O.K. next line is to handle special case of final newline // automatically added by jEdit to saved files if (caret+attrVal == blen+1) buffer.insert(blen, "\n"); block = buffer.getText(caret, attrVal); buffer.remove(caret, attrVal); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_REFACTORING_CUT_BLOCK); return(i); } public static int dispatchPasteBlock(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { Buffer buffer = s.getBuffer(); int caret = s.getCaretPosition(); buffer.insert(caret, block); // do indentation somewhere later to not perturb refactorings offsets //&int blocklines = s.getNumberOfCharOccurences(block,'\n'); //&int line = buffer.getLineOfOffset(caret); //&buffer.indentLines(buffer.getLineOfOffset(caret), line+blocklines); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_REFACTORING_PASTE_BLOCK); return(i); } public static int dispatchKillBufferRemoveFile(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String message = ss.substring( i, i+attrLen); i += attrLen; int confirm = JOptionPane.YES_OPTION; confirm = JOptionPane.showConfirmDialog( s.view, message, "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.YES_OPTION) { Buffer buf = s.getBuffer(); buf.save(s.view, null); (new File(buf.getPath())).delete(); jEdit.closeBuffer(s.view, buf); } i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_KILL_BUFFER_REMOVE_FILE); return(i); } public static int dispatchIndent(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { Buffer buffer = s.getBuffer(); int caret = s.getCaretPosition(); int line = buffer.getLineOfOffset(caret); buffer.indentLines(line, line+attrVal-1); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_INDENT); return(i); } public static int dispatchExtractDialog(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { String xtype = attrType; i += attrLen; i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); String invocation = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTag(ss, i, len); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); String theHead = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTag(ss, i, len); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_STRING_VALUE); String theTail = ss.substring( i, i+attrLen); i += attrLen; i = parseXmlTag(ss, i, len); protocolCheckEq(currentTag, "/"+Protocol.PPC_STRING_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, Protocol.PPC_INT_VALUE); int targetLine = attrVal; i += attrLen; i = parseXmlTag(ss, i, len); protocolCheckEq(currentTag, "/"+Protocol.PPC_INT_VALUE); i = parseXmlTagHandleMessages(ss, i, len,data); protocolCheckEq(currentTag, "/"+Protocol.PPC_EXTRACTION_DIALOG); new ExtractMethodDialog(invocation, theHead, theTail, targetLine, xtype); return(i); } public static int dispatchRecordAt(XrefCharBuffer ss, int i, int len, DispatchData data) throws Exception { int j; String unenclosed; i = s.skipBlank(ss, i, len); for(j=i; ss.buf[i] != '<' && i<len; i++) ; if (i!=j && s.debug) { unenclosed = ss.substring(j, i); JOptionPane.showMessageDialog(s.view, "Unenclosed string\n" + unenclosed, "Xrefactory Error", JOptionPane.ERROR_MESSAGE); } if (j>=len) throw new XrefException("unexpected end of communication"); clearAttributes(); i = parseXmlTagHandleMessages(ss, i, len,data); if (i>=len || data.panic) { // no action in such cases } else if (currentTag.equals(Protocol.PPC_SINGLE_COMPLETION)) { i = dispatchSingleCompletion(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_FQT_COMPLETION)) { i = dispatchFqtCompletion(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_MULTIPLE_COMPLETIONS)) { i = dispatchCompletionList(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_FULL_MULTIPLE_COMPLETIONS)) { i = dispatchFullCompletionList(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_ALL_COMPLETIONS)) { i = dispatchAllCompletionsList(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_SYMBOL_LIST)) { i = dispatchSymbolList(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_SET_PROJECT)) { i = dispatchSetProject(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_SET_INFO)) { i = dispatchSetInfo(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_NO_PROJECT)) { i = dispatchNoProject(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_NO_SYMBOL)) { i = dispatchNoSymbol(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_UPDATE_CURRENT_REFERENCE)) { i = dispatchUpdateCurrentReference(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_BROWSE_URL)) { i = dispatchBrowseUrl(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_GOTO)) { i = dispatchGoto(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFACTORING_PRECHECK)) { i = dispatchPreCheck(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFACTORING_REPLACEMENT)) { i = dispatchReplacement(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_DISPLAY_OR_UPDATE_BROWSER)) { i = dispatchDisplayOrUpdateBrowser(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_DISPLAY_CLASS_TREE)) { i = dispatchDisplayClassTree(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_DISPLAY_RESOLUTION)) { i = dispatchDisplayResolution(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_SYMBOL_RESOLUTION)) { i = dispatchSymbolResolution(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFERENCE_LIST)) { i = dispatchReferenceList(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_ASK_CONFIRMATION)) { i = dispatchAskConfirmation(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_FILE_SAVE_AS)) { i = dispatchFileSaveAs(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_MOVE_FILE_AS)) { i = dispatchMoveFileAs(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_MOVE_DIRECTORY)) { i = dispatchMoveDirectory(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_AVAILABLE_REFACTORINGS)) { i = dispatchAvailableRefactorings(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFACTORING_COPY_BLOCK)) { i = dispatchCopyBlock(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFACTORING_CUT_BLOCK)) { i = dispatchCutBlock(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_REFACTORING_PASTE_BLOCK)) { i = dispatchPasteBlock(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_KILL_BUFFER_REMOVE_FILE)) { i = dispatchKillBufferRemoveFile(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_INDENT)) { i = dispatchIndent(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_EXTRACTION_DIALOG)) { i = dispatchExtractDialog(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_UPDATE_REPORT)) { i = dispatchUpdateReport(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_VERSION_MISMATCH)) { i = dispatchVersionMismatch(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_PROGRESS)) { i = dispatchProgress(ss, i, len, data); } else if (currentTag.equals(Protocol.PPC_SYNCHRO_RECORD)) { // this is usualy a problem, but ignore it for debuging } else { throw new XrefException("unknown XML Tag " + currentTag); } return(i); } public static void dispatch(XrefCharBuffer ss, DispatchData data) { //&JOptionPane.showMessageDialog(s.getProbableParent(data.callerComponent), ss, "Got", JOptionPane.INFORMATION_MESSAGE); if (s.debug) System.err.println("Dispatching: " + ss); int i = 0; int len = ss.length(); try { i = s.skipBlank(ss, i, len); while (i<len && ! data.panic) { i = dispatchRecordAt(ss, i, len, data); i = s.skipBlank(ss, i, len); } } catch (XrefAbortException e) { data.panic = true; } catch (XrefErrorException e) { if (s.debug) e.printStackTrace(System.err); JOptionPane.showMessageDialog(s.getProbableParent(data.callerComponent), e, "Xrefactory Error", JOptionPane.ERROR_MESSAGE); data.panic = true; } catch (Exception e) { JOptionPane.showMessageDialog(s.getProbableParent(data.callerComponent), e, "Xrefactory Internal Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); data.panic = true; } } public static String reportToHtml(XrefCharBuffer ss) { XrefCharBuffer res = new XrefCharBuffer(); int i, len; i = 0; len = ss.length(); res.append("<html><pre>\n"); try { while (i<len) { clearAttributes(); i = parseXmlTag(ss, i, len); if (currentTag.equals(Protocol.PPC_ERROR) || currentTag.equals(Protocol.PPC_FATAL_ERROR) || currentTag.equals(Protocol.PPC_WARNING) ) { res.append("<font color=red>"); int j = attrLen; while (j>0 && Character.isWhitespace(ss.buf[i+j-1])) j--; res.append(ss.substring(i, i+j)); res.append("</font>\n"); i += attrLen; i = parseXmlTag(ss, i, len); } else if (currentTag.equals(Protocol.PPC_INFORMATION) || currentTag.equals(Protocol.PPC_BOTTOM_INFORMATION) ) { res.append("<font color=gray>"); res.append(ss.substring(i, i+attrLen)); res.append("</font>\n"); i += attrLen; i = parseXmlTag(ss, i, len); } else { res.append(ss.substring(i, i+attrLen)); res.append("\n"); i += attrLen; } i = s.skipBlank(ss, i, len); } } catch(Exception e) { e.printStackTrace(System.err); JOptionPane.showMessageDialog(s.view, "Problem while parsing report " + e, "Xrefactory Error", JOptionPane.ERROR_MESSAGE); } res.append("\n</pre></html>\n"); if (s.debug) System.err.println("HTML == \n" + res.toString()); return(res.toString()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -