⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s.java

📁 emacs的一个非常有用的插件,叫xrefactory,可以实现source insight里的那种函数跳转.和cscope(跳回来不方便)配合使用,非常的不错.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			);		Dispatch.dispatch(receipt, ndata);		if (ndata.panic) return(null);		return(ndata.info);	}		public static String computeSomeInformationInXref(Component parent, String[] options) {		DispatchData ndata = new DispatchData(xbTask, parent);		XrefCharBuffer receipt = ndata.xTask.callProcessOnFileNoSaves(			options, ndata);		Dispatch.dispatch(receipt, ndata);		if (ndata.panic) return(null);		return(ndata.info);	}		public static String getOrComputeActiveProject() {		if (activeProject == null) {			activeProject = computeActiveProject(view,true);		}		return(activeProject);	}	public static void displayProjectInformationLater() {		String message;		String project = getOrComputeActiveProject();		if (project == null) {			message = "Can't infer Xrefactory project!";		} else {			message = "Xrefactory project: " + project;		}		// O.K. display it later, so io messages do not overwrite it		SwingUtilities.invokeLater(new MessageDisplayer(message,true));	}	static public char getBufferChar(Buffer buffer, int offset) {		return(buffer.getText(offset,1).charAt(0));	}	static boolean projectExists(String name, Options[] projects) {		int i;		for(i=0; i<projects.length; i++) {			if (projects[i].projectName.equals(name)) return(true);		}		return(false);	}	static public String commonPrefix(String s1, String s2) {		int i,l1,l2;		l1 = s1.length();		l2 = s2.length();		for(i=0; i<l1 && i<l2; i++) {			if (s1.charAt(i) != s2.charAt(i)) break;		}		return(s1.substring(0, i));	}	static public String getIdentifierOnCaret() {		Buffer buffer = getBuffer();		int len = buffer.getLength();		int offset = getCaretPosition();		if (offset == len) return("");		int j = offset;		while (j>0 && Character.isJavaIdentifierPart(getBufferChar(buffer, j))) {			j --;		}		if (j>0) j++;		int i = j;		//&if (Character.isJavaIdentifierStart(getBufferChar(buffer, i))) {		while (i<len && Character.isJavaIdentifierPart(getBufferChar(buffer, i))) {			i ++;		}		//&}		return(buffer.getText(j, i-j));	}	static public String getIdentifierBeforeCaret() {		Buffer buffer = getBuffer();		int len = buffer.getLength();		int offset = getCaretPosition();		if (offset == len) return("");		int j = offset - 1;		while (j>0 && Character.isJavaIdentifierPart(getBufferChar(buffer, j))) {			j --;		}		if (j>0) j++;		if (j>=offset) return("");		return(buffer.getText(j, offset-j));	}	static public String getIdentifierAfterCaret() {		Buffer buffer = getBuffer();		int len = buffer.getLength();		int offset = getCaretPosition();		if (offset == len) return("");		int i = offset;		while (i<len && Character.isJavaIdentifierPart(getBufferChar(buffer, i))) {			i ++;		}		return(buffer.getText(offset, i-offset));	}	public static Point getAbsCoordinate(Point pp, Component cc) {		double x = pp.getX();		double y = pp.getY();		while (cc!=null) {			x += cc.getX();			y += cc.getY();			cc = cc.getParent();		}		return(new Point((int)x, (int)y));	}		public static Point recommendedLocation(Component cc) {		//&int line = getTextArea().getCaretLine();		//&int vline = getTextArea().getFoldVisibilityManager().physicalToVirtual(line);		//&int offset = getTextArea().getCaretPosition() - getTextArea().getLineStartOffset(line);		Point pp = getTextArea().offsetToXY(getTextArea().getCaretPosition());		if (pp==null) {			JOptionPane.showMessageDialog(view, "Can't get caret position", 										  "Xrefactory Error", JOptionPane.ERROR_MESSAGE);			pp = new Point(100,100);		} else {			pp = getAbsCoordinate(pp, cc);		}		FontMetrics fm = getTextArea().getPainter().getFontMetrics();		return(new Point((int)pp.getX(), (int)pp.getY() + fm.getHeight()));	}	public static void moveOnScreen(Component cc) {		Point ccloc = cc.getLocation();		int x = (int)ccloc.getX();		int y = (int)ccloc.getY();		Dimension ccdimm = cc.getSize();		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();//&System.err.println("Checking "+ccloc.getX()+" "+ccdimm.getWidth()+" "+dim.getWidth());		if (x < 0) x = 0;		if (x+ccdimm.getWidth() > dim.getWidth()) {			x = (int)(dim.getWidth()-ccdimm.getWidth());		}		if (y < 0) y = 0;		if (y+ccdimm.getHeight() > dim.getHeight()) {			y = (int)(dim.getHeight()-ccdimm.getHeight());		}		cc.setLocation(x, y);	}		static public String dotifyString(String ss) {		String res;		res = ss;		res = res.replace('/','.');		res = res.replace('\\','.');		return(res);	}	static public int getNumberOfCharOccurences(String s, char c) {		int i,n;		i = n = 0;		while ((i=s.indexOf(c, i)) != -1) {			i++;			n++;		}		return(n);	}	static public void arrayCopyDelElement(Object[] src, Object[] dest, int i) {		System.arraycopy(src, 0, dest, 0, i);		System.arraycopy(src, i+1, dest, i, src.length-i-1);	}	static public void arrayCopyAddElement(Object[] src, Object[] dest, int i) {		System.arraycopy(src, 0, dest, 0, i);		dest[i] = null;		System.arraycopy(src, i, dest, i+1, src.length-i);	}	static public String upperCaseFirstLetter(String s) {		String res = s;		int slen = s.length();		if (slen>0) res = s.substring(0,1).toUpperCase() + s.substring(1);		return(res);	}	static public String lowerCaseFirstLetter(String s) {		String res = s;		int slen = s.length();		if (slen>0) res = s.substring(0,1).toLowerCase() + s.substring(1);		return(res);	}	// PARENTS COMPONENTS	static public Component getProbableParent(Component c) {		Component res, cc;		res = cc = c;		while (cc!=null && ! (res instanceof Window)) {			res = cc;			cc = cc.getParent();		}		if (res==null) res = view;		return(res);	}	static public View getParentView(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof View)) {			cc = cc.getParent();		}		if (cc==null) cc = view;		return((View)cc);	}	static public JDialog getParentDialog(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof JDialog)) {			cc = cc.getParent();		}		return((JDialog)cc);	}	static public JFrame getParentFrame(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof JFrame)) {			cc = cc.getParent();		}		return((JFrame)cc);	}	static public ResolutionPanel getParentResolutionPanel(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof ResolutionPanel)) cc = cc.getParent();		return((ResolutionPanel)cc);	}	static public DockableBrowser getParentBrowserPanel(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof DockableBrowser)) cc = cc.getParent();		return((DockableBrowser)cc);	}	static public BrowserTopPanel getParentBrowserTopPanel(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof BrowserTopPanel)) cc = cc.getParent();		return((BrowserTopPanel)cc);	}	static public BrowserTopPanel.TreePanel getParentTreePanel(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof BrowserTopPanel.TreePanel)) cc = cc.getParent();		return((BrowserTopPanel.TreePanel)cc);	}	static public BrowserTopPanel.ReferencesPanel getParentReferencesPanel(Component c) {		Component cc;		cc = c;		while (cc!=null && ! (cc instanceof BrowserTopPanel.ReferencesPanel)) cc = cc.getParent();		return((BrowserTopPanel.ReferencesPanel)cc);	}	// ------------------------------------------	public static String getViewParameter(int viewId) {		return("view"+viewId);		}		public static boolean synchronizedUpdateTagFile(Component parent) {		String updateOption;		if (Opt.fullAutoUpdate()) updateOption = "-update";		else updateOption = "-fastupdate";		//&updateOption = "-create";		DispatchData ndata = new DispatchData(xbTask, parent);		XrefTaskForTagFile tr = XrefTaskForTagFile.runXrefOnTagFile(updateOption, "Updating Tags.", false, ndata);		if (tr == null) return(true);		synchronized (tr.lock) {			try {				if (tr.running) tr.lock.wait();			} catch(Exception e) {				e.printStackTrace();			}		}		return(tr.data.panic);	}	public static void dumpMemoryStatus() {		Runtime runtime = Runtime.getRuntime();		int freeMemory = (int)(runtime.freeMemory() / 1024);		int totalMemory = (int)(runtime.totalMemory() / 1024);		System.err.println(" memory " + freeMemory + "/" + totalMemory);	}	public static void saveAllBuffers(View view) {		jEdit.saveAllBuffers(view, Opt.saveFilesAskForConfirmation());		try {Thread.currentThread().sleep(100);} catch (InterruptedException e){}		VFSManager.waitForRequests();	}	public static void showTagFileReport(XrefCharBuffer report, Component caller) {		try {			if (debug) System.err.println("report=="+report.toString());			if (report.bufi != 0) {				String message;				if (report.bufi > s.MAX_FILE_SIZE_FOR_REPORT) {					message = "Done. The report is "+report.bufi+" chars long and may run jEdit out of memory. View the report anyway ?";				} else {					message = "Done. View report ?";				}				int confirm = JOptionPane.YES_OPTION;				confirm = JOptionPane.showConfirmDialog(					getParentView(caller),					message, "Confirmation", 					JOptionPane.YES_NO_OPTION,					JOptionPane.QUESTION_MESSAGE);				if (confirm == JOptionPane.YES_OPTION) {					SwingUtilities.invokeLater(						new TagReportDisplayer(Dispatch.reportToHtml(report), caller)							);				}			}		} catch (Exception e) {			e.printStackTrace(System.err);			JOptionPane.showMessageDialog(view, "While reading report file: " + e, 										  "Xrefactory Error", JOptionPane.ERROR_MESSAGE);		}	}	public static String getExternBrowserName() {		if (osName.toLowerCase().indexOf("linux") != -1) return("mozilla");		if (osName.toLowerCase().indexOf("sunos") != -1) return("netscape");		if (osName.toLowerCase().indexOf("mac-os-x") != -1) return("konqueror");		if (osName.toLowerCase().indexOf("unix") != -1) return("netscape");		return("CMD /C start");	}	public static void browseUrl(String url, boolean externBrowser, View view) {		if (externBrowser) {			String bb = getExternBrowserName();			try {				Runtime.getRuntime().exec(bb+" "+url);			} catch (Exception e) {			}		} else {			/*&			if (s.javaVersion.compareTo("1.4.0") < 0) {				if (url.length()>9 && url.substring(0, 9).toLowerCase().equals("file:////")) {					url = "file:///" +  url.substring(9);				}			}			&*/			view.getStatus().setMessageAndClear("Url: "+url);			view.getDockableWindowManager().showDockableWindow(dockableUrlBrowserWindowName);			DockableUrlBrowser urlViewer = (DockableUrlBrowser)view.getDockableWindowManager().getDockableWindow(dockableUrlBrowserWindowName);			urlViewer.setPreferredSize(new Dimension(400,400));			urlViewer.gotoURL(url, true);		}		//&SwingUtilities.invokeLater(new MessageDisplayer("Url "+url, true));	}	public static void insertCompletionDoNotMoveCaret(Buffer buffer, int offset, String completion) {		int 		b, i, blen;		String 		ss;		if (jEdit.getBooleanProperty(s.optCompletionDelPendingId)) {			ss = completion;		} else {			ss = completion + completionIdAfterCaret;		}		b = i = offset;		blen = buffer.getLength();		while (i<blen && Character.isJavaIdentifierPart(buffer.getText(i,1).charAt(0))) i++;		int cidlen = i-b;		String cid = buffer.getText(b, i-b);		String cprefix = commonPrefix(cid, ss);		int cprefixlen = cprefix.length();		buffer.remove(b+cprefixlen, cidlen-cprefixlen);		buffer.insert(b+cprefixlen, ss.substring(cprefixlen));	}	public static void insertCompletion(Buffer buffer, int offset, String completion) {		insertCompletionDoNotMoveCaret(buffer, offset, completion);		getTextArea().setCaretPosition(offset+completion.length());	}	// following code is taken from jEdit4.1, all the credits belong to Slava Pestov	public static JToolBar loadToolBar(String name) {		JToolBar toolBar = new JToolBar();		toolBar.setFloatable(false);		String buttons = jEdit.getProperty(name);		if(buttons != null) {			StringTokenizer st = new StringTokenizer(buttons);			while(st.hasMoreTokens()) {				String button = st.nextToken();				if(button.equals("-")) {					toolBar.addSeparator();				} else {					JButton b = GUIUtilities.loadToolButton(button);					if(b != null) toolBar.add(b);				}			}		}		return toolBar;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -