本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.getFileName方法的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnitDeclaration.getFileName方法的具体用法?Java CompilationUnitDeclaration.getFileName怎么用?Java CompilationUnitDeclaration.getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration
的用法示例。
在下文中一共展示了CompilationUnitDeclaration.getFileName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ownerName
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; //导入方法依赖的package包/类
private String ownerName() {
CompilationUnitDeclaration node = owner.get();
if (node == null) return "--GCed--";
char[] tn = node.getMainTypeName();
char[] fs = node.getFileName();
if (tn == null || tn.length == 0) {
return (fs == null || fs.length == 0) ? "--UNKNOWN--" : new String(fs);
}
return new String(tn);
}
示例2: duplicateTypes
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; //导入方法依赖的package包/类
public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
int end = typeDecl.sourceEnd;
if (end <= 0) {
end = -1;
}
this.handle(
IProblem.DuplicateTypes,
arguments,
arguments,
typeDecl.sourceStart,
end,
compUnitDecl.compilationResult);
}
示例3: publicClassMustMatchFileName
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; //导入方法依赖的package包/类
public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.PublicClassMustMatchFileName,
arguments,
arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
示例4: typeCollidesWithPackage
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; //导入方法依赖的package包/类
public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.TypeCollidesWithPackage,
arguments,
arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
示例5: parse
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; //导入方法依赖的package包/类
/** Parse the given source units and class path and store it into the given output map */
public static INameEnvironment parse(
CompilerOptions options,
@NonNull List<ICompilationUnit> sourceUnits,
@NonNull List<String> classPath,
@NonNull Map<ICompilationUnit, CompilationUnitDeclaration> outputMap,
@Nullable LintClient client) {
INameEnvironment environment = new FileSystem(
classPath.toArray(new String[classPath.size()]), new String[0],
options.defaultEncoding);
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
// Not used; we need the corresponding CompilationUnitDeclaration for the source
// units (the AST parsed from source) which we don't get access to here, so we
// instead subclass AST to get our hands on them.
}
};
NonGeneratingCompiler compiler = new NonGeneratingCompiler(environment, policy, options,
requestor, problemFactory, outputMap);
try {
compiler.compile(sourceUnits.toArray(new ICompilationUnit[sourceUnits.size()]));
} catch (OutOfMemoryError e) {
environment.cleanup();
// Since we're running out of memory, if it's all still held we could potentially
// fail attempting to log the failure. Actively get rid of the large ECJ data
// structure references first so minimize the chance of that
//noinspection UnusedAssignment
compiler = null;
//noinspection UnusedAssignment
environment = null;
//noinspection UnusedAssignment
requestor = null;
//noinspection UnusedAssignment
problemFactory = null;
//noinspection UnusedAssignment
policy = null;
String msg = "Ran out of memory analyzing .java sources with ECJ: Some lint checks "
+ "may not be accurate (missing type information from the compiler)";
if (client != null) {
// Don't log exception too; this isn't a compiler error per se where we
// need to pin point the exact unlucky code that asked for memory when it
// had already run out
client.log(null, msg);
} else {
System.out.println(msg);
}
} catch (Throwable t) {
if (client != null) {
CompilationUnitDeclaration currentUnit = compiler.getCurrentUnit();
if (currentUnit == null || currentUnit.getFileName() == null) {
client.log(t, "ECJ compiler crashed");
} else {
client.log(t, "ECJ compiler crashed processing %1$s",
new String(currentUnit.getFileName()));
}
} else {
t.printStackTrace();
}
environment.cleanup();
environment = null;
}
return environment;
}