6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup

Reviewed-by: bpatel
This commit is contained in:
Jonathan Gibbons 2011-03-04 19:53:03 -08:00
parent cc52e2d413
commit 42bc55bf32
15 changed files with 95 additions and 89 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -64,7 +64,6 @@ import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Position;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
/**
@ -147,6 +146,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
/**
* Return true if this is a class, not an interface.
*/
@Override
public boolean isClass() {
return !Modifier.isInterface(getModifiers());
}
@ -155,6 +155,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return true if this is a ordinary class,
* not an enumeration, exception, an error, or an interface.
*/
@Override
public boolean isOrdinaryClass() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@ -172,6 +173,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return true if this is an enumeration.
* (For legacy doclets, return false.)
*/
@Override
public boolean isEnum() {
return (getFlags() & Flags.ENUM) != 0
&&
@ -182,6 +184,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return true if this is an interface, but not an annotation type.
* Overridden by AnnotationTypeDocImpl.
*/
@Override
public boolean isInterface() {
return Modifier.isInterface(getModifiers());
}
@ -189,6 +192,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
/**
* Return true if this is an exception class
*/
@Override
public boolean isException() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@ -204,6 +208,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
/**
* Return true if this is an error class
*/
@Override
public boolean isError() {
if (isEnum() || isInterface() || isAnnotationType()) {
return false;
@ -275,6 +280,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
/**
* Return the package that this class is contained in.
*/
@Override
public PackageDoc containingPackage() {
PackageDocImpl p = env.getPackageDoc(tsym.packge());
if (p.setDocPath == false) {
@ -374,6 +380,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return the qualified name and any type parameters.
* Each parameter is a type variable with optional bounds.
*/
@Override
public String toString() {
return classToString(env, tsym, true);
}
@ -401,7 +408,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* qualified by their enclosing class(es) only.
*/
static String classToString(DocEnv env, ClassSymbol c, boolean full) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
if (!c.isInner()) { // if c is not an inner class
s.append(getClassName(c, full));
} else {
@ -449,10 +456,12 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return the modifier string for this class. If it's an interface
* exclude 'abstract' keyword from the modifier string
*/
@Override
public String modifiers() {
return Modifier.toString(modifierSpecifier());
}
@Override
public int modifierSpecifier() {
int modifiers = getModifiers();
return (isInterface() || isAnnotationType())
@ -1285,6 +1294,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return the source position of the entity, or null if
* no position is available.
*/
@Override
public SourcePosition position() {
if (tsym.sourcefile == null) return null;
return SourcePositionImpl.make(tsym.sourcefile,