?? options.java
字號:
package com.xrefactory.jedit;import java.util.*;import java.io.*;import javax.swing.*;class Options { public static final int OPT_GENERAL = 0; public static final int OPT_COMMON = 1; public static final int OPT_PROJECT = 2; public static final int OPT_BOTH = 3; static public class OptionDescription { String name; int nameLen; int arity; boolean compact; String shortDescription; String longDescription; boolean interactive; int kind; // OPT_... boolean addAtBeginning; boolean recreateTagsIfModified; // 'bd' - browse directories // 'bf' - browse files // 'bfd' - browse files and directories String fileSystemBrowseOptions; OptionDescription(String name, boolean interactive, int kind, int arity, boolean compact, String shortDescription, String longDescription, String fileSystemBrowseOptions, boolean addAtBeginning, // not needed anymore boolean recreateTagsIfModified ) { this.interactive = interactive; this.name = name; this.nameLen = name.length(); this.arity = arity; this.kind = kind; this.compact = compact; this.shortDescription = shortDescription; this.longDescription = longDescription; this.fileSystemBrowseOptions = fileSystemBrowseOptions; this.addAtBeginning = false; //addAtBeginning; this.recreateTagsIfModified = recreateTagsIfModified; } } public static OptionDescription optFilesCaseUnSensitive = new OptionDescription( "-filescaseunsensitive", false, OPT_GENERAL, 1, true, "File names are considered case unsensitive", "File names are considered case unsensitive", null,false,true); public static OptionDescription optJavaVersion = new OptionDescription( "-source", true, OPT_BOTH, 2, false, "Sources are written in Java: ", "Java version in which sources are written.", null, false,true); public static OptionDescription optCSuffixes = new OptionDescription( "-csuffixes=", false, OPT_BOTH, 2, true, "Suffixes determining C sources: ", "Identify files with those suffixes as C sources", null, true,true); public static OptionDescription optJavaSuffixes = new OptionDescription( "-javasuffixes=", false, OPT_BOTH, 2, true, "Suffixes determining Java sources: ", "Identify files with those suffixes as Java sources", null, true,true); public static OptionDescription optProjectMarker = new OptionDescription( "[",true, OPT_PROJECT, 2, true, "Project auto detection directories: ", "Project auto detection directories", "p",false,false); public static OptionDescription optInputFile = new OptionDescription( "", true,OPT_PROJECT, 2, true, "Source files & directories: ", "Source files & directories", "p",false,true); public static OptionDescription optPruneDirs = new OptionDescription( "-prune", true,OPT_PROJECT, 2, false, "Prune directories: ", "Prune directories", "p",false,true); public static OptionDescription optRecurseDirs = new OptionDescription( "--r", false, OPT_PROJECT, 1, true, "Do not descent into subdirectories when looking for input files", "Do not descent into subdirectories when looking for input files", null, true,true); public static OptionDescription optXrefsFile = new OptionDescription( "-refs",true,OPT_PROJECT, 2, false, "Place to store Tags: ", "Place to store Tag", "fd",false,true); public static OptionDescription optXrefNum = new OptionDescription( "-refnum=",false,OPT_PROJECT, 2, true, "Number of Tag files: ", "Number of Tag files", null,false,true); public static OptionDescription optCommentOption = new OptionDescription( "//",false,OPT_BOTH, 0, true, "Comment", "Comment", null,false,false); public static OptionDescription optClassPath = new OptionDescription( "-classpath",true,OPT_BOTH, 2, false, "Classpath: ", "Top directories with .class files (classpath)", "p",false,true); public static OptionDescription optSourcePath = new OptionDescription( "-sourcepath",true,OPT_BOTH, 2, false, "Sourcepath: ", "Top directories with source code (sourcepath)", "p",false,true); public static OptionDescription optJavaDocPath = new OptionDescription( "-javadocpath",true,OPT_BOTH, 2, false, "Javadocpath: ", "Top directories with javadoc documentation (javadocpath)", "p",false,false); public static OptionDescription optJdkClassPath = new OptionDescription( "-jdkclasspath",true,OPT_BOTH, 2, false, "Jdk runtime library (rt.jar): ", "Jdk runtime library (rt.jar)", "p",false,true); public static OptionDescription optLicense = new OptionDescription( "-license=",true,OPT_COMMON, 2, true, "License string: ", "License string", null,false,false); public static OptionDescription[] allOptions = { optInputFile, // must be first! // regular options optPruneDirs, optRecurseDirs, optCSuffixes, optJavaSuffixes, optLicense, optClassPath, optSourcePath, optJavaDocPath, optJavaVersion, optXrefNum, optProjectMarker, optXrefsFile, optJdkClassPath,//& new OptionDescription("-include",true,OPT_BOTH, 2, false, //& "Include option file",//& "Include option file",//& "f", false), // not interactive options optCommentOption, new OptionDescription("-set",false,OPT_BOTH, 3, false, "Set a user defined variable: ", "Set a user defined variable", "fd",false,false), new OptionDescription("-refs=",false,OPT_PROJECT, 2, true, "Place to store Tags: ", "Place to store Tags", "fd",false,true), }; // --------------------- ClassPathIterator ------------------------ public static class PathIterator { String ss; int sslen; int i; String separator; public String next( ) { String res; int j = ss.indexOf(separator, i); if (j == -1) { res = ss.substring(i); i = sslen+1; } else { res = ss.substring(i, j); i = j+1; } return(res); } public boolean hasNext( ) { return(i<sslen); } public void remove( ) { } PathIterator(String ss, String separator) { this.ss = ss; this.separator = separator; sslen = ss.length(); i = 0; } } // ------------------------- Option ------------------------------- static class Option { OptionDescription option; String[] fulltext; // includes option name Option(OptionDescription desc) { option = desc; fulltext = new String[] {desc.name}; } Option(OptionDescription desc, String optval) { option = desc; fulltext = new String[] {desc.name, optval}; } Option(OptionDescription desc, String[] optvals) { option = desc; fulltext = new String[optvals.length+1]; fulltext[0] = desc.name; for(int i=0; i<optvals.length; i++) { fulltext[i+1] = optvals[i]; } } Option(Option o) { int i; this.option = o.option; this.fulltext = new String[o.fulltext.length]; for(i=0; i<o.fulltext.length; i++) { this.fulltext[i] = o.fulltext[i]; } } } // ------------------------- OptionParser --------------------------- static class OptionParser { XrefCharBuffer ss; int sslen; int ind; private static OptionDescription getOptionDescription(String opt) { int i; // options must be tested in reverse order, because of source files!!! for(i=allOptions.length-1; i>=0; i--) { OptionDescription o = allOptions[i]; if ((o.compact && opt.length() >= o.nameLen && opt.substring(0, o.nameLen).equals(o.name)) || (!o.compact) && opt.equals(o.name)) { return(o); } } return(null); } String parseOptItem() { String opt; int b,j; b = ind = s.skipBlank(ss, ind, sslen); if (ind<sslen && ss.buf[ind]=='"') { ind++; while (ind<sslen && ss.buf[ind]!='"') ind++; opt = ss.substring(b+1, ind); ind++; } else { while (ind<sslen && !Character.isWhitespace(ss.buf[ind])) ind++; opt = ss.substring(b,ind); } // following is useless, but it looks better while ((j=opt.indexOf("${dq}"))!=-1) { opt = opt.substring(0,j) + "\"" + opt.substring(j+5); } return(opt); } private Option parseOption() throws XrefErrorException { String opt; Option res=null; int b; b = ind = s.skipBlank(ss, ind, sslen); if (ind<sslen && ss.buf[ind]=='[') { while (ind<sslen && ss.buf[ind]!=']') ind++; opt = ss.substring(b+1, ind); ind++; return(new Option(optProjectMarker, opt)); } else { opt = parseOptItem(); } OptionDescription desc = getOptionDescription(opt); if (desc==null) throw new XrefErrorException("unknown option "+opt); if (desc.name.equals("//")) { // comment b = ind; while (ind<sslen && ss.buf[ind]!='\n') ind++; String oval = opt.substring(2) + ss.substring(b,ind); return(new Option(desc, oval)); } if (desc.compact) { return(new Option(desc, opt.substring(desc.nameLen))); } String[] vals = new String[desc.arity-1]; for(int i=1; i<desc.arity; i++) { vals[i-1] = parseOptItem(); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -