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

📄 textuicommandline.java

📁 A static analysis tool to find bugs in Java programs
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		} else if (option.equals("-sourceInfo")) {			sourceInfoFile = argument;		} else if (option.equals("-visitors") || option.equals("-omitVisitors")) {			boolean omit = option.equals("-omitVisitors");			if (!omit) {				// Selecting detectors explicitly, so start out by				// disabling all of them.  The selected ones will				// be re-enabled.				getUserPreferences().enableAllDetectors(false);			}			// Explicitly enable or disable the selected detectors.			StringTokenizer tok = new StringTokenizer(argument, ",");			while (tok.hasMoreTokens()) {				String visitorName = tok.nextToken();				DetectorFactory factory = DetectorFactoryCollection.instance().getFactory(visitorName);				if (factory == null)					throw new IllegalArgumentException("Unknown detector: " + visitorName);				getUserPreferences().enableDetector(factory, !omit);			}		} else if (option.equals("-chooseVisitors")) {			// This is like -visitors and -omitVisitors, but			// you can selectively enable and disable detectors,			// starting from the default set (or whatever set			// happens to be in effect).			choose(argument, "Detector choices", new Chooser() {				public void choose(boolean enabled, String what) {					DetectorFactory factory = DetectorFactoryCollection.instance().getFactory(what);					if (factory == null)						throw new IllegalArgumentException("Unknown detector: " + what);					if (FindBugs.DEBUG) {						System.err.println("Detector " + factory.getShortName() + " " +								(enabled ? "enabled" : "disabled") +								", userPreferences="+System.identityHashCode(getUserPreferences()));					}					getUserPreferences().enableDetector(factory, enabled);				}			});		} else if (option.equals("-choosePlugins")) {			// Selectively enable/disable plugins			choose(argument, "Plugin choices", new Chooser() {				public void choose(boolean enabled, String what) {					Plugin plugin = DetectorFactoryCollection.instance().getPluginById(what);					if (plugin == null)						throw new IllegalArgumentException("Unknown plugin: " + what);					plugin.setEnabled(enabled);				}			});		} else if (option.equals("-adjustPriority")) {			// Selectively raise or lower the priority of warnings			// produced by specified detectors.			StringTokenizer tok = new StringTokenizer(argument, ",");			while (tok.hasMoreTokens()) {				String token = tok.nextToken();				int eq = token.indexOf('=');				if (eq < 0)					throw new IllegalArgumentException("Illegal priority adjustment: " + token);				String visitorName = token.substring(0, eq);				DetectorFactory factory = DetectorFactoryCollection.instance().getFactory(visitorName);				if (factory == null)					throw new IllegalArgumentException("Unknown detector: " + visitorName);				String adjustment = token.substring(eq + 1);				if (!(adjustment.equals("raise") || adjustment.equals("lower")))					throw new IllegalArgumentException("Illegal priority adjustment value: " +							adjustment);				// Recall that lower values are higher priorities				factory.setPriorityAdjustment(adjustment.equals("raise") ? -1 : +1);			}		} else if (option.equals("-bugCategories")) {			this.bugCategorySet = FindBugs.handleBugCategories(getUserPreferences(), argument);		} else if (option.equals("-onlyAnalyze")) {			// The argument is a comma-separated list of classes and packages			// to select to analyze.  (If a list item ends with ".*",			// it specifies a package, otherwise it's a class.)			StringTokenizer tok = new StringTokenizer(argument, ",");			while (tok.hasMoreTokens()) {				String item = tok.nextToken();				if (item.endsWith(".-"))					classScreener.addAllowedPrefix(item.substring(0, item.length() - 1));				else if (item.endsWith(".*"))					classScreener.addAllowedPackage(item.substring(0, item.length() - 1));				else					classScreener.addAllowedClass(item);			}		} else if (option.equals("-exclude")) {			if (excludeFilterFile != null) 				throw new IllegalArgumentException("Can specify one exclude filter file");			excludeFilterFile = argument;		} else if (option.equals("-include")) {			if (includeFilterFile != null) 				throw new IllegalArgumentException("Can specify one include filter file");			includeFilterFile = argument;		} else if (option.equals("-auxclasspath")) {			StringTokenizer tok = new StringTokenizer(argument, File.pathSeparator);			while (tok.hasMoreTokens())				project.addAuxClasspathEntry(tok.nextToken());		} else if (option.equals("-sourcepath")) {			StringTokenizer tok = new StringTokenizer(argument, File.pathSeparator);			while (tok.hasMoreTokens())				project.addSourceDir(new File(tok.nextToken()).getAbsolutePath());		} else {			super.handleOptionWithArgument(option, argument);		}	}	/**	 * Common handling code for -chooseVisitors and -choosePlugins options.	 *	 * @param argument the list of visitors or plugins to be chosen	 * @param desc     String describing what is being chosen	 * @param chooser  callback object to selectively choose list members	 */	private void choose(String argument, String desc, Chooser chooser) {		StringTokenizer tok = new StringTokenizer(argument, ",");		while (tok.hasMoreTokens()) {			String what = tok.nextToken();			if (!what.startsWith("+") && !what.startsWith("-"))				throw new IllegalArgumentException(desc + " must start with " +						"\"+\" or \"-\" (saw " + what + ")");			boolean enabled = what.startsWith("+");			chooser.choose(enabled, what.substring(1));		}	}	public void configureEngine(IFindBugsEngine findBugs) throws IOException, FilterException {		// Load plugins		DetectorFactoryCollection.instance().ensureLoaded();		// Set the DetectorFactoryCollection (that has been configured		// by command line parsing)		findBugs.setDetectorFactoryCollection(DetectorFactoryCollection.instance());		TextUIBugReporter textuiBugReporter;		switch (bugReporterType) {		case PRINTING_REPORTER:			textuiBugReporter = new PrintingBugReporter();			break;		case SORTING_REPORTER:			textuiBugReporter = new SortingBugReporter();			break;		case XML_REPORTER:			{				XMLBugReporter xmlBugReporter = new XMLBugReporter(project);				xmlBugReporter.setAddMessages(xmlWithMessages);				textuiBugReporter = xmlBugReporter;			}			break;		case EMACS_REPORTER:			textuiBugReporter = new EmacsBugReporter();			break;		case HTML_REPORTER:			textuiBugReporter = new HTMLBugReporter(project, stylesheet);			break;		case XDOCS_REPORTER:			textuiBugReporter = new XDocsBugReporter(project);			break;		default:			throw new IllegalStateException();		}		if (quiet)			textuiBugReporter.setErrorVerbosity(BugReporter.SILENT);		textuiBugReporter.setPriorityThreshold(priorityThreshold);		textuiBugReporter.setUseLongBugCodes(useLongBugCodes);		if (outputStream != null)			textuiBugReporter.setOutputStream(outputStream);		BugReporter bugReporter = textuiBugReporter;		if (bugCategorySet != null) {			bugReporter = new CategoryFilteringBugReporter(bugReporter, bugCategorySet);		}		findBugs.setBugReporter(bugReporter);		findBugs.setProject(project);		findBugs.setUserPreferences(getUserPreferences());		if (includeFilterFile != null) 			findBugs.addFilter(includeFilterFile, true);		if (excludeFilterFile != null) 			findBugs.addFilter(excludeFilterFile, false);		findBugs.setClassScreener(classScreener);		findBugs.setRelaxedReportingMode(relaxedReportingMode);		findBugs.setAbridgedMessages(xmlWithAbridgedMessages);		if (trainingOutputDir != null) {			findBugs.enableTrainingOutput(trainingOutputDir);		}		if (trainingInputDir != null) {			findBugs.enableTrainingInput(trainingInputDir);		}		if (sourceInfoFile != null) {			findBugs.setSourceInfoFile(sourceInfoFile);		}		findBugs.setAnalysisFeatureSettings(settingList);		findBugs.setReleaseName(releaseName);		findBugs.setProjectName(projectName);		findBugs.setScanNestedArchives(scanNestedArchives);	}	/**	 * Handle -xargs command line option by reading	 * jar file names from standard input and adding them	 * to the project.	 * 	 * @throws IOException	 */	public void handleXArgs() throws IOException {		if (getXargs()) {			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));			while (true) {				String s = in.readLine();				if (s == null) break;				project.addFile(s);			}		}	}	/**	 * @param userPreferences The userPreferences to set.	 */	private void setUserPreferences(UserPreferences userPreferences) {		this.userPreferences = userPreferences;	}	/**	 * @return Returns the userPreferences.	 */	private UserPreferences getUserPreferences() {		if (userPreferences == null) 			userPreferences = UserPreferences.createDefaultUserPreferences();		return userPreferences;	}}

⌨️ 快捷键说明

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