当前位置: 首页>>代码示例>>Java>>正文


Java SourceVersion类代码示例

本文整理汇总了Java中javax.lang.model.SourceVersion的典型用法代码示例。如果您正苦于以下问题:Java SourceVersion类的具体用法?Java SourceVersion怎么用?Java SourceVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SourceVersion类属于javax.lang.model包,在下文中一共展示了SourceVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillIn

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private void fillIn(PackageSymbol p,
                    Location location,
                    Iterable<JavaFileObject> files) {
    currentLoc = location;
    for (JavaFileObject fo : files) {
        switch (fo.getKind()) {
            case CLASS:
            case SOURCE: {
                // TODO pass binaryName to includeClassFile
                String binaryName = fileManager.inferBinaryName(currentLoc, fo);
                String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
                if (SourceVersion.isIdentifier(simpleName) ||
                        simpleName.equals("package-info"))
                    includeClassFile(p, fo);
                break;
            }
            default:
                extraFileActions(p, fo);
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:ClassReader.java

示例2: resolveIdent

import javax.lang.model.SourceVersion; //导入依赖的package包/类
/**
 * Resolve an identifier.
 *
 * @param name The identifier to resolve
 */
public Symbol resolveIdent(String name) {
    if (name.equals(""))
        return syms.errSymbol;
    JavaFileObject prev = log.useSource(null);
    try {
        JCExpression tree = null;
        for (String s : name.split("\\.", -1)) {
            if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
                return syms.errSymbol;
            tree = (tree == null) ? make.Ident(names.fromString(s))
                    : make.Select(tree, names.fromString(s));
        }
        JCCompilationUnit toplevel =
                make.TopLevel(List.<JCAnnotation>nil(), null, List.<JCTree>nil());
        toplevel.packge = syms.unnamedPackage;
        return attr.attribIdent(tree, toplevel);
    } finally {
        log.useSource(prev);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:JavaCompiler.java

示例3: correctMethodParameterName

import javax.lang.model.SourceVersion; //导入依赖的package包/类
public static String correctMethodParameterName(String paramName) {
  if (SourceVersion.isName(paramName)) {
    return paramName;
  }
  StringBuffer newParam = new StringBuffer();
  char tempChar;
  for (int index = 0; index < paramName.length(); index++) {
    tempChar = paramName.charAt(index);
    if (Character.isJavaIdentifierPart(tempChar)) {
      newParam.append(paramName.charAt(index));
    } else if (tempChar == '.' || tempChar == '-') {
      newParam.append('_');
    }
  }
  return newParam.toString();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:ClassUtils.java

示例4: addOptionButtonActionPerformed

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private void addOptionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOptionButtonActionPerformed
    final AddProcessorOption panel = new AddProcessorOption();
    final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage (CustomizerCompile.class, "LBL_AddProcessorOption_Title")); //NOI18N
    desc.setValid(false);
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            String key = panel.getOptionKey();
            for(String s : key.split("\\.", -1)) { //NOI18N
                if (!SourceVersion.isIdentifier(s)) {
                    desc.setValid(false);
                    return;
                }
            }
            desc.setValid(true);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible (true);
    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        ((DefaultTableModel)processorOptionsTable.getModel()).addRow(new String[] {panel.getOptionKey(), panel.getOptionValue()});
    }
    dlg.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CustomizerCompile.java

示例5: adjustName

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private static String adjustName(String name) {
    if (name == null) {
        return null;
    }
    String shortName = null;
    if (name.startsWith("get") && name.length() > 3) { //NOI18N
        shortName = name.substring(3);
    }
    if (name.startsWith("is") && name.length() > 2) { //NOI18N
        shortName = name.substring(2);
    }
    if (shortName != null) {
        return firstToLower(shortName);
    }
    if (SourceVersion.isKeyword(name)) {
        return "a" + Character.toUpperCase(name.charAt(0)) + name.substring(1); //NOI18N
    } else {
        return name;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaCompletionItem.java

示例6: firstToLower

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private static String firstToLower(String name) {
    if (name.length() == 0) {
        return null;
    }
    StringBuilder result = new StringBuilder();
    boolean toLower = true;
    char last = Character.toLowerCase(name.charAt(0));
    for (int i = 1; i < name.length(); i++) {
        if (toLower && Character.isUpperCase(name.charAt(i))) {
            result.append(Character.toLowerCase(last));
        } else {
            result.append(last);
            toLower = false;
        }
        last = name.charAt(i);
    }
    result.append(last);
    if (SourceVersion.isKeyword(result)) {
        return "a" + name; //NOI18N
    } else {
        return result.toString();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JavaCompletionItem.java

示例7: generateComment

import javax.lang.model.SourceVersion; //导入依赖的package包/类
public String generateComment(VariableElement field, CompilationInfo javac) {
        StringBuilder builder = new StringBuilder(
//                "/**\n" + // NOI18N
                "\n" // NOI18N
                );
        
        if (SourceVersion.RELEASE_5.compareTo(srcVersion) <= 0 &&
                JavadocUtilities.isDeprecated(javac, field)) {
            builder.append("@deprecated\n"); // NOI18N
        }
        

//        builder.append("*/\n"); // NOI18N
        
        return builder.toString();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavadocGenerator.java

示例8: isValidOptionName

import javax.lang.model.SourceVersion; //导入依赖的package包/类
public static boolean isValidOptionName(String optionName) {
    for(String s : optionName.split("\\.", -1)) {
        if (!SourceVersion.isIdentifier(s))
            return false;
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavacProcessingEnvironment.java

示例9: getSupportedSourceVersion

import javax.lang.model.SourceVersion; //导入依赖的package包/类
@Override
public SourceVersion getSupportedSourceVersion() {
    /*
     * Return latest source version instead of a fixed version
     * like RELEASE_9. To return a fixed version, this class could
     * be annotated with a SupportedSourceVersion annotation.
     *
     * Warnings will be issued if any unknown language constructs
     * are encountered.
     */
    return SourceVersion.latest();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:CheckNamesProcessor.java

示例10: isValidName

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private static boolean isValidName(String name) {
    // Arguably, isValidName should reject keywords (such as in SourceVersion.isName() ),
    // but the set of keywords depends on the source level, and we don't want
    // impls of JavaFileManager to have to be dependent on the source level.
    // Therefore we simply check that the argument is a sequence of identifiers
    // separated by ".".
    for (String s : name.split("\\.", -1)) {
        if (!SourceVersion.isIdentifier(s))
            return false;
    }
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:13,代码来源:JavacFileManager.java

示例11: isValidImportString

import javax.lang.model.SourceVersion; //导入依赖的package包/类
/**
 * Return true if the argument string is a valid import-style
 * string specifying claimed annotations; return false otherwise.
 */
public static boolean isValidImportString(String s) {
    if (s.equals("*"))
        return true;

    boolean valid = true;
    String t = s;
    int index = t.indexOf('*');

    if (index != -1) {
        // '*' must be last character...
        if (index == t.length() -1) {
            // ... any and preceding character must be '.'
            if ( index-1 >= 0 ) {
                valid = t.charAt(index-1) == '.';
                // Strip off ".*$" for identifier checks
                t = t.substring(0, t.length()-2);
            }
        } else
            return false;
    }

    // Verify string is off the form (javaId \.)+ or javaId
    if (valid) {
        String[] javaIds = t.split("\\.", t.length()+2);
        for(String javaId: javaIds)
            valid &= SourceVersion.isIdentifier(javaId);
    }
    return valid;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:34,代码来源:JavacProcessingEnvironment.java

示例12: toConstantName

import javax.lang.model.SourceVersion; //导入依赖的package包/类
public String toConstantName( String token ) {
    String name = super.toConstantName(token);
    if(!SourceVersion.isKeyword(name))
        return name;
    else
        return '_'+name;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:NameConverter.java

示例13: getSupportedSourceVersion

import javax.lang.model.SourceVersion; //导入依赖的package包/类
/**
 * If the processor class is annotated with {@link
 * SupportedSourceVersion}, return the source version in the
 * annotation.  If the class is not so annotated, {@link
 * SourceVersion#RELEASE_6} is returned.
 *
 * @return the latest source version supported by this processor
 */
public SourceVersion getSupportedSourceVersion() {
    SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
    SourceVersion sv = null;
    if (ssv == null) {
        sv = SourceVersion.RELEASE_6;
        if (isInitialized())
            processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
                                                     "No SupportedSourceVersion annotation " +
                                                     "found on " + this.getClass().getName() +
                                                     ", returning " + sv + ".");
    } else
        sv = ssv.value();
    return sv;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AbstractProcessor.java

示例14: doGetElement

import javax.lang.model.SourceVersion; //导入依赖的package包/类
private <S extends Symbol> S doGetElement(ModuleElement module, String methodName,
                                          CharSequence name, Class<S> clazz) {
    String strName = name.toString();
    if (!SourceVersion.isName(strName) && (!strName.isEmpty() || clazz == ClassSymbol.class)) {
        return null;
    }
    if (module == null) {
        return unboundNameToSymbol(methodName, strName, clazz);
    } else {
        return nameToSymbol((ModuleSymbol) module, strName, clazz);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JavacElements.java

示例15: sourceVersion

import javax.lang.model.SourceVersion; //导入依赖的package包/类
public @NonNull SourceVersion sourceVersion() {
    String sourceLevel = SourceLevelQuery.getSourceLevel(ctx.getInfo().getFileObject());

    if (sourceLevel == null) {
        return SourceVersion.latest(); //TODO
    }

    String[] splited = sourceLevel.split("\\.");
    String   spec    = splited[1];

    return SourceVersion.valueOf("RELEASE_"+  spec);//!!!
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Context.java


注:本文中的javax.lang.model.SourceVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。