本文整理汇总了Java中javax.lang.model.SourceVersion.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java SourceVersion.compareTo方法的具体用法?Java SourceVersion.compareTo怎么用?Java SourceVersion.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.SourceVersion
的用法示例。
在下文中一共展示了SourceVersion.compareTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeHints
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
@CheckForNull
public Map<HintDescription, List<ErrorDescription>> computeHints(CompilationInfo info,
TreePath startAt,
boolean recursive,
Iterable<? extends HintDescription> hints,
Collection<? super MessageImpl> problems) {
Map<Class, List<HintDescription>> triggerKind2Hints = new HashMap<Class, List<HintDescription>>();
for (Class<? extends Trigger> c : TRIGGER_KINDS) {
triggerKind2Hints.put(c, new ArrayList<HintDescription>());
}
SourceVersion srcVersion = info.getSourceVersion();
for (HintDescription hd : hints) {
SourceVersion hVersion = hd.getMetadata().sourceVersion;
if (hVersion != null &&
(srcVersion.compareTo(hVersion) < 0)) {
continue;
}
List<HintDescription> sorted = triggerKind2Hints.get(hd.getTrigger().getClass());
sorted.add(hd);
}
if (caret != -1) {
TreePath tp = info.getTreeUtilities().pathFor(caret);
return computeSuggestions(info, tp, true, triggerKind2Hints, problems);
} else {
if (from != (-1) && to != (-1)) {
return computeHintsInSpan(info, triggerKind2Hints, problems);
} else if (!recursive) {
return computeSuggestions(info, startAt, false, triggerKind2Hints, problems);
} else {
return computeHintsImpl(info, startAt, triggerKind2Hints, problems);
}
}
}
示例2: checkSourceVersionCompatibility
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
/**
* Checks whether or not a processor's source version is
* compatible with the compilation source version. The
* processor's source version needs to be greater than or
* equal to the source version of the compile.
*/
private void checkSourceVersionCompatibility(Source source, Log log) {
SourceVersion procSourceVersion = processor.getSupportedSourceVersion();
if (procSourceVersion.compareTo(Source.toSourceVersion(source)) < 0 ) {
log.warning("proc.processor.incompatible.source.version",
procSourceVersion,
processor.getClass().getName(),
source.name);
}
}
示例3: checkSourceVersionCompatibility
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
/**
* Checks whether or not a processor's source version is
* compatible with the compilation source version. The
* processor's source version needs to be greater than or
* equal to the source version of the compile.
*/
private void checkSourceVersionCompatibility(Source source, Log log) {
SourceVersion procSourceVersion = processor.getSupportedSourceVersion();
if (procSourceVersion.compareTo(Source.toSourceVersion(source)) < 0 ) {
log.warning(Warnings.ProcProcessorIncompatibleSourceVersion(procSourceVersion,
processor.getClass().getName(),
source.name));
}
}
示例4: testEnclosingElement
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
void testEnclosingElement(PackageElement javaLang) {
SourceVersion version = processingEnv.getSourceVersion();
Element enclosing = javaLang.getEnclosingElement();
Element expectedEnclosing =
(version.compareTo(RELEASE_9) < 0) ? // No modules
null :
eltUtils.getModuleElement("java.base");
if (!Objects.equals(enclosing, expectedEnclosing))
throw new RuntimeException("Unexpected enclosing element under source version " +
version);
}
示例5: isJava8
import javax.lang.model.SourceVersion; //导入方法依赖的package包/类
public boolean isJava8() {
SourceVersion sourceVersion = StaticEnvironment.processing().getSourceVersion();
return sourceVersion.compareTo(SourceVersion.RELEASE_7) > 0;
}