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

📄 s.java

📁 emacs的一个非常有用的插件,叫xrefactory,可以实现source insight里的那种函数跳转.和cscope(跳回来不方便)配合使用,非常的不错.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
					progressi += n;				}				if (! progress.setProgress(progressi*100/progressn)) {					// cancel					n = -2;				}			}			ii.close();			oo.close();			fileSetExecPermission(file);			if (n == -2) {				// canceled				of.delete();			}		} catch(Exception e) {			try {				if (oo!=null) {					oo.close();					new File(file).delete();				}				if (ii!=null) ii.close();			} catch (Exception ee) {}			progress.setVisible(false);			JOptionPane.showMessageDialog(				null,				e.toString()+"\nWhile downloading "+url+".\nMaybe wrong proxy configuration?", 				"Xrefactory Error",				JOptionPane.ERROR_MESSAGE);		}		progress.setVisible(false);	}	public static void setGlobalValues() {		String deftmp, defslash, defcpsep, defcfile, deftask, downloadtask, instdir;		// non settable property, should be always false in normal installations		debug = jEdit.getBooleanProperty("xrefactory.debug-mode", debug);		javaVersion = System.getProperty("java.version","1.3.0");		osName = System.getProperty("os.name").toLowerCase();		archName = System.getProperty("os.arch").toLowerCase();		if (osName.equals("mac os x")) osName = "mac-os-x";		if (osName.indexOf("windows") != -1) osName = "windows";		if (osName.indexOf("os/2") != -1) osName = "os2";		if (archName.indexOf("86") != -1) archName = "x86";		if (debug) {			System.err.println("[Xrefactory] os == " + osName);			System.err.println("[Xrefactory] arch == " + archName);		}		if (osName.toLowerCase().indexOf("windows") != -1) {			osCode = OS_WINDOWS;			rootDir = "C:\\";			deftmp = "C:\\";			defslash = "\\";			defcpsep = ";";			defcfile = "_xrefrc";			deftask = "xref.exe";			homeDir = System.getProperty("user.home","c:\\");		} else if (osName.equals("os2")) {			osCode = OS_OS2;			rootDir = "C:\\";			deftmp = "C:\\";			defslash = "\\";			defcpsep = ";";			defcfile = ".xrefrc";			deftask = "xref.exe";			homeDir = System.getProperty("user.home","c:\\");		} else {			osCode = OS_OTHER;			rootDir = "/";			deftmp = "/tmp/";			defslash = "/";			defcpsep = ":";			defcfile = ".xrefrc";				deftask = "xref";			homeDir = System.getProperty("user.home","~/");		}		downloadtask = "xref-" + Protocol.XREF_VERSION_NUMBER + "-" + osName + "-" + archName + ".exe";		xrefTaskUrl = xrefTaskDirUrl + downloadtask;		slash = System.getProperty("file.separator", defslash);		classPathSeparator = System.getProperty("path.separator", defcpsep);   		tmpDirectoryPath = System.getProperty("java.io.tmpdir", deftmp);		if (tmpDirectoryPath.substring(tmpDirectoryPath.length()) != slash) {			tmpDirectoryPath = tmpDirectoryPath + slash;		}		if (homeDir.substring(homeDir.length()) != slash) {			homeDir = homeDir + slash;		}		javaHome = System.getProperty("java.home", rootDir);		if (javaHome.substring(javaHome.length()) != slash) {			javaHome = javaHome + slash;		}				instdir = "/"; 		String cp = System.getProperty("java.class.path");		if (cp!=null) {			//& JOptionPane.showMessageDialog(this, cp);			int i = cp.toLowerCase().indexOf("jedit.jar");			//&if (i == -1) i = cp.toLowerCase().indexOf("xrefac~1.jar");			if (i != -1) {				String ss = cp.substring(0, i);				int j = ss.lastIndexOf(classPathSeparator);				if (j != -1) ss = ss.substring(j+1);				instdir = ss + "jars" + slash;			}		}		pluginInstallationPath = "";		xrefTaskPath = "xref";		String path0 = jEdit.getSettingsDirectory();		if (path0!=null) path0 = path0+slash+"jars"+slash;		String path1 = homeDir+".jedit"+slash+"jars"+slash;		String path2 = homeDir+"jedit"+slash+"jars"+slash;		if (path0!=null && new File(path0+"Xrefactory.jar").exists()) {			pluginInstallationPath = path0;		} else if (new File(path1+"Xrefactory.jar").exists()) {			pluginInstallationPath = path1;		} else if (new File(path2+"Xrefactory.jar").exists()) {			pluginInstallationPath = path2;		} else if (new File(instdir+"Xrefactory.jar").exists()) {			pluginInstallationPath = instdir;		} else {			System.err.println("[Xrefactory] can't find installation directory.");			System.err.println("[Xrefactory] neither "+path0+", "+path1+", ");			System.err.println("[Xrefactory] "+path2+" or "+instdir+" contains Xrefactory.jar");		}		xrefTaskPath = pluginInstallationPath+"Xrefactory"+slash+deftask;		jdkClassPath = javaHome + "lib" + slash + "rt.jar";		configurationFile = jEdit.getProperty(configurationFileOption);		if (configurationFile==null || configurationFile.equals("none")) {			configurationFile = new File(homeDir + defcfile).getAbsolutePath();			jEdit.setProperty(configurationFileOption, configurationFile);		}		tagFilesDirectory = homeDir + "Xrefs" + slash;		tagProcessingReportFile = tmpDirectoryPath + xrefLogFileSingleName;		activeProject = null;	}	public static void checkIfXrefTaskExists() {		if (xrefTaskYetChecked) return;		xrefTaskYetChecked = true;		File taskfile = new File(xrefTaskPath);		if ((! taskfile.exists()) && ! jEdit.getProperty(tryInstallXrefOption).equals(Protocol.XREF_VERSION_NUMBER)){			Object confirm = JOptionPane.showInputDialog(				null,				"You have  installed Xrefactory plugin. It requires shareware 'xref'\nnot  distributed with  the  plugin. However, xref can be  freely\ndownloaded   and   evaluated.   Can   I   download   xref   into\nfile: "+xrefTaskPath+"?",				"Xrefactory installation",				JOptionPane.QUESTION_MESSAGE,				null,				new String[] {"Yes", "No", "No and do not display this dialog anymore"},				"Yes");			if ("Yes".equals(confirm)) {				downloadXrefTask(xrefTaskUrl, xrefTaskPath);			} else if (answerNoAndDoNotAskAnymore.equals (confirm)) {				// never				jEdit.setProperty(tryInstallXrefOption, Protocol.XREF_VERSION_NUMBER);			}		}		if (! taskfile.exists()) xrefTaskPath = "xref";	}	public static void checkVersionCorrespondance(String taskVersion, DispatchData data) {		if (! taskVersion.equals(Protocol.XREF_VERSION_NUMBER)) {			int confirm = JOptionPane.showConfirmDialog(				getProbableParent(data.callerComponent),				"You have installed Xrefactory version "+Protocol.XREF_VERSION_NUMBER+" while using\nxref  task version  "+taskVersion+". Version mismatch  may cause\nproblems during  execution. Can I download correct  version of\nxref task?",				"Xrefactory Problem",				JOptionPane.YES_NO_OPTION,				JOptionPane.QUESTION_MESSAGE);			if (confirm == JOptionPane.YES_OPTION) {				xbTask.killThis(false);				downloadXrefTask(xrefTaskUrl, xrefTaskPath);				data.panic = true;		// restart task			}		}	}	public static void checkBrowserTask() {		if (xbTask==null) {			// this is the first invocation of Xrefactory			cleanOldTmpFiles();			checkIfXrefTaskExists();			xbTask = new BrowserTask();			// check version			DispatchData ndata = new DispatchData(xbTask, view);			XrefCharBuffer receipt = ndata.xTask.callProcessSingleOpt(				"-olcheckversion=" + Protocol.XREF_VERSION_NUMBER, ndata);			Dispatch.dispatch(receipt, ndata);			if (ndata.panic) {				xbTask = new BrowserTask();			}		}	}	public static void setGlobalValuesNoActiveProject(View view) {		s.view = view;		panic = false;		checkBrowserTask();		//& setGlobalValues();	}	public static void setGlobalValues(View view, boolean projectCreationAllowed) {		setGlobalValuesNoActiveProject(view);		//&if (activeProject == null) {		activeProject = computeActiveProject(s.view, projectCreationAllowed);		//&}	}	public static Position getPosition(View v) {		Position res = new Position(			v, 			v.getBuffer().getPath(),			v.getTextArea().getCaretPosition()			);		return(res);	}	public static void moveToPosition(View view, String file, int off) {		Buffer buf = jEdit.openFile(view, file);		// wait until operation completes		VFSManager.waitForRequests();		JEditTextArea texta = view.getTextArea();		texta.setCaretPosition(off);		VFSManager.waitForRequests();	}	public static void moveToPosition(Position p) {		moveToPosition(p.view, p.file, p.offset);	}	public static void moveToPosition(View view,String file, int line, int col) {		Buffer buf = jEdit.openFile(view, file);		VFSManager.waitForRequests();		JEditTextArea texta = view.getTextArea();		int off = 0;		int offmax = 0;		try {			off = texta.getLineStartOffset(line-1);			offmax = texta.getLineEndOffset(line-1);			off = off + col;			if (off > offmax) off = offmax;			texta.setCaretPosition(off);			VFSManager.waitForRequests();		} catch (Exception eee) {			if (debug) System.err.println("Problem while moving to "+file+" "+line+" "+col);		}	}	public static void assertt(boolean b) {		if (! b) {			(new Exception()).printStackTrace();			JOptionPane.showMessageDialog(view, 										  "An assertion Failed, an internal problem occurs.", 										  "Xrefactory Error", 										  JOptionPane.ERROR_MESSAGE);		}	}	public static int countLines(String s) {		int i,n;		i= -1; n=0;		while((i=s.indexOf('\n', i+1)) != -1) n++;		if (n>0 || s.length()>0) n++;		return(n);	}		public static String sprintOption(String ss) {		String res;		int i,ii;		if (ss.indexOf(" ") == -1 			&& ss.indexOf("\"") == -1 			&& (!ss.equals("")) 			&& !(ss.charAt(0)=='"')			) {			res = ss;		} else {			res = "\"";			ii = 0;			while ((i=ss.indexOf('"',ii))!=-1) {				res += ss.substring(ii, i) + "${dq}";				ii = i+1;			}			res += ss.substring(ii);			res += "\"";		}		return(res);	}	public static boolean stringArrayEqual(String[] a1, String[] a2) {		if (a1.length != a2.length) return(false);		for(int i=0; i<a1.length; i++) {			if (! a1[i].equals(a2[i])) return(false);		}		return(true);	}	public static int skipNumber(XrefCharBuffer ss, int i, int len) {		char	c;		c = ss.buf[i];		while (i<len && Character.isDigit(c)) {			i++;			c = ss.buf[i];		}		return(i);	}	public static int skipBlank(XrefCharBuffer ss, int i, int len) {		while (i<len && Character.isWhitespace(ss.buf[i])) i++;		return(i);	}	private static GridBagConstraints gbc = new GridBagConstraints();		public static void addGbcComponent(Container pane, 									   int x, int y, 									   int w, int h, 									   int wx, int wy, 									   int fill,									   Component cc) {		gbc.gridx = x; gbc.gridy = y; 		gbc.gridwidth = w; gbc.gridheight = h;		gbc.weightx = wx; gbc.weighty = wy; gbc.fill = fill;		pane.add(cc, gbc);	}	public static void addButtonLine(JPanel panel, int y, JComponent [] components,									 boolean borders) {		int i,x;		x = -1;				if (borders) {			x++;			addGbcComponent(panel, x,y, 1,1, 10,10, 							GridBagConstraints.HORIZONTAL,							new JPanel());		}		for(i=0; i<components.length; i++) {			x++;			addGbcComponent(panel, x,y, 1,1, 1,10, 							GridBagConstraints.HORIZONTAL,							components[i]);		}		if (borders) {			x++;			addGbcComponent(panel, x,y, 1,1, 10,10, 							GridBagConstraints.HORIZONTAL,							new JPanel());		}	}	public static void addExtraButtonLine(Container thiss, int x, int y, int dx, int dy,										  int wx, int wy, JComponent [] buttons,										  boolean borders) {		JPanel bp = new JPanel();		bp.setLayout(new GridBagLayout());		addButtonLine(bp, 0, buttons, borders);		addGbcComponent(thiss, x, y, dx, dy, wx, wy, 						GridBagConstraints.HORIZONTAL,						bp);	}	public static void buttonsSetFont(JComponent [] buttons, Font font) {		int i;		for(i=0; i<buttons.length; i++) buttons[i].setFont(font);	}	public static void buttonsAddActionListener(JButton [] buttons, ActionListener listener) {		int i;		for(i=0; i<buttons.length; i++) buttons[i].addActionListener(listener);	}	public static String computeActiveProject(Component parent, boolean projectCreationAllowed) {		DispatchData ndata = new DispatchData(xbTask, parent);		ndata.projectCreationAllowed = projectCreationAllowed;		xbTask.tmpOption.clear();		xbTask.tmpOption.add("-olcxgetprojectname");		//& xbTask.addCommonOptions(xbTask.tmpOption, ndata);		xbTask.addCurrentFileOptions(xbTask.tmpOption);		XrefCharBuffer receipt = xbTask.callProcess(xbTask.tmpOption, ndata);		Dispatch.dispatch(receipt, ndata);		if (ndata.panic) return(null);		return(ndata.info);	}	static void performMovingRefactoring(String moption, String fieldOption) {		if (targetLine>0 && !targetFile.equals("")) {			XrefStringArray xroption = new XrefStringArray();			xroption.add(moption);			xroption.add("-commentmovinglevel=" + 						 jEdit.getIntegerProperty(optRefactoryCommentMovingLevel,0));			xroption.add("-movetargetfile="+targetFile);			xroption.add("-rfct-param1="+targetLine);			if (fieldOption!=null) {				xroption.add("-rfct-param2="+fieldOption);			}			Refactorings.mainRefactorerInvocation(xroption,false);		}	}		public static String computeSomeInformationInXref(Component parent, String option) {		DispatchData ndata = new DispatchData(xbTask, parent);		XrefCharBuffer receipt = ndata.xTask.callProcessOnFileNoSaves(			new String[]{option}, 			ndata

⌨️ 快捷键说明

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