Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.core;singleton:=true
Bundle-Version: 1.4.600.qualifier
Bundle-Version: 1.4.700.qualifier
Bundle-Activator: org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Map<String, String> getOptions() {

private Function<Entry<String, String>, String> replacePlaceholdersUsing(Map<String, String> commandLineOptions) {
return option -> {
String variable, replacement, optionValue = option.getValue();
String variable, replacement, optionValue = option.getValue() == null ? "" : option.getValue();
Matcher placeholder = Pattern.compile("%([^%]+)%").matcher(optionValue);
if (placeholder.find() && (variable = placeholder.group(1)) != null
&& (replacement = commandLineOptions.get(variable)) != null) {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.tests;singleton:=true
Bundle-Version: 3.6.800.qualifier
Bundle-Version: 3.6.900.qualifier
Bundle-Activator: org.eclipse.jdt.apt.pluggable.tests.Apt6TestsPlugin
Bundle-Localization: plugin
Require-Bundle: org.junit,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.apt.pluggable.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<relativePath>../tests-pom/</relativePath>
</parent>
<artifactId>org.eclipse.jdt.apt.pluggable.tests</artifactId>
<version>3.6.800-SNAPSHOT</version>
<version>3.6.900-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,25 @@ public void testBug341298() throws Throwable {
fullBuild();
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
}
public void testGHIssue4640() throws Throwable {
ProcessorTestStatus.reset();
IJavaProject project = createJavaProject(_projectName);
IPath root = project.getProject().getFullPath().append("src");
env.addClass(root, "test341298", "Annotated",
"package test341298;\n" +
"@Annotation public class Annotated {}"
);
env.addClass(root, "test341298", "Annotation",
"package test341298;\n" +
"public @interface Annotation {}"
);
AptConfig.addProcessorOption(project, "classpath", "%classpath%");
AptConfig.addProcessorOption(project, "sourcepath", "%sourcepath%");
AptConfig.addProcessorOption(project, "phase", null);
AptConfig.setEnabled(project, true);
fullBuild();
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
}

public void testBug539663() throws Throwable {
if (!canRunJava9()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,8 @@ public static void isTypeUseCompatible(TypeReference reference, Scope scope, Ann

nextAnnotation:
for (Annotation annotation : annotations) {
if (annotation.resolvedType == null) // barked elsewhere or still cooking and we come here due to re-entrancy
continue;
long metaTagBits = annotation.resolvedType.getAnnotationTagBits();
if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0 && (metaTagBits & TagBits.AnnotationForDeclarationMASK) == 0) {
ReferenceBinding currentType = (ReferenceBinding) resolvedType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public VisibilityInspector(FunctionalExpression expression, Scope scope, boolean
}

private void checkVisibility(ReferenceBinding referenceBinding) {
if (referenceBinding.isUnresolvedType())
referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.scope.environment(), false);
if (!referenceBinding.canBeSeenBy(this.scope)) {
this.visible = false;
if (this.shouldChatter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ public TypeBinding resolveType(BlockScope scope) {
}
}

RecordComponentBinding[] componentBindings = this.resolvedType.components();
LocalVariableBinding [] bindings = NO_VARIABLES;
for (int i = 0, l = this.patterns.length; i < l; ++i) {
Pattern p = this.patterns[i];
p.setOuterExpressionType(componentBindings[i].type);
p.resolveTypeWithBindings(bindings, scope);
bindings = LocalVariableBinding.merge(bindings, p.bindingsWhenTrue());
p.setOuterExpressionType(this.resolvedType.components()[i].type);
}

if (this.resolvedType == null || !this.resolvedType.isValidBinding()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,9 @@ void buildComponents() {

void connectTypeHierarchy() {
SourceTypeBinding sourceType = this.referenceContext.binding;
boolean previousFlag = environment().enterSuperTypeLookup(sourceType);
if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) == 0) {
sourceType.tagBits |= TagBits.BeginHierarchyCheck;
environment().typesBeingConnected.add(sourceType);
boolean noProblems = connectSuperclass();
noProblems &= connectSuperInterfaces();
if ((sourceType.typeBits & (TypeIds.BitAutoCloseable|TypeIds.BitCloseable)) != 0) {
Expand All @@ -1412,6 +1412,7 @@ void connectTypeHierarchy() {
throw e;
} finally {
env.missingClassFileLocation = null;
env.root.isResolvingSuperType = previousFlag;
}
}

Expand All @@ -1429,17 +1430,20 @@ private void connectTypeHierarchyWithoutMembers() {
SourceTypeBinding sourceType = this.referenceContext.binding;
if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) != 0)
return;

sourceType.tagBits |= TagBits.BeginHierarchyCheck;
environment().typesBeingConnected.add(sourceType);
boolean noProblems = connectSuperclass();
noProblems &= connectSuperInterfaces();
environment().typesBeingConnected.remove(sourceType);
sourceType.tagBits |= TagBits.EndHierarchyCheck;
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
if (noProblems && sourceType.isHierarchyInconsistent())
problemReporter().hierarchyHasProblems(sourceType);
boolean previousFlag = environment().enterSuperTypeLookup(sourceType);
try {
sourceType.tagBits |= TagBits.BeginHierarchyCheck;
boolean noProblems = connectSuperclass();
noProblems &= connectSuperInterfaces();
environment().typesBeingConnected.remove(sourceType);
sourceType.tagBits |= TagBits.EndHierarchyCheck;
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
if (noProblems && sourceType.isHierarchyInconsistent())
problemReporter().hierarchyHasProblems(sourceType);
} finally {
environment().root.isResolvingSuperType = previousFlag;
}
}

public boolean detectHierarchyCycle(TypeBinding superType, TypeReference reference) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
private ArrayList<MissingTypeBinding> missingTypes;
final Set<SourceTypeBinding> typesBeingConnected; // SHARED
public boolean isProcessingAnnotations = false; // ROOT_ONLY
public boolean isResolvingSuperType = false; // ROOT_ONLY
public boolean mayTolerateMissingType = false;

AnnotationBinding nonNullAnnotation;
Expand Down Expand Up @@ -154,21 +155,34 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
static class GlobalDataMemento {
Set<SourceTypeBinding> typesBeingConnected;
boolean mayTolerateMissingType = false;
GlobalDataMemento(Set<SourceTypeBinding> typesBeingConnected, boolean mayTolerateMissingType) {
boolean isResolvingSuperType = false;
GlobalDataMemento(Set<SourceTypeBinding> typesBeingConnected, boolean mayTolerateMissingType, boolean isResolvingSuperType) {
this.typesBeingConnected = typesBeingConnected;
this.mayTolerateMissingType = mayTolerateMissingType;
this.isResolvingSuperType = isResolvingSuperType;
}
}
GlobalDataMemento stashGlobalData() {
GlobalDataMemento memento = new GlobalDataMemento(new LinkedHashSet<>(this.typesBeingConnected), this.mayTolerateMissingType);
this.typesBeingConnected.clear();
GlobalDataMemento memento = new GlobalDataMemento(new LinkedHashSet<>(this.typesBeingConnected),
this.mayTolerateMissingType, this.root.isResolvingSuperType);
if (!this.root.isResolvingSuperType)
this.typesBeingConnected.clear(); // lookup is not within the hierarchy of these types
this.root.isResolvingSuperType = false;
this.mayTolerateMissingType = false;
return memento;
}
void restoreFrom(GlobalDataMemento memento) {
this.typesBeingConnected.clear();
this.typesBeingConnected.addAll(memento.typesBeingConnected);
this.mayTolerateMissingType = memento.mayTolerateMissingType;
this.root.isResolvingSuperType = memento.isResolvingSuperType;
}

public boolean enterSuperTypeLookup(SourceTypeBinding sourceType) {
this.typesBeingConnected.add(sourceType);
boolean previous = this.root.isResolvingSuperType;
this.root.isResolvingSuperType = true;
return previous;
}

static enum CompleteTypeBindingsSteps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ protected boolean commentParse() {
considerTagAsPlainText = false; // re-enable tag validation
}
}
boolean isLiteralOrCode = this.tagValue == TAG_LITERAL_VALUE || this.tagValue == TAG_CODE_VALUE;
if (this.inlineTagStarted) {
textEndPosition = this.index - 1;
boolean treatAsText= considerTagAsPlainText || (this.inlineReturn && this.inlineReturnOpenBraces > 0);
Expand All @@ -377,8 +378,12 @@ protected boolean commentParse() {
}
if (!isFormatterParser && !treatAsText && (!this.inlineReturn || this.inlineReturnOpenBraces <= 0))
this.textStart = this.index;
if ((!isTagElementClose && this.markdown) || !this.markdown) { //The comment parser should create a TagElement only if the previous one is closed - markdown.
if (!isTagElementClose && this.markdown) { //The comment parser should create a TagElement only if the previous one is closed - markdown.
setInlineTagStarted(false);
} else if (!this.markdown) {
if (!(isLiteralOrCode && openingBraces != 0)) {
setInlineTagStarted(false);
}
}
if (this.inlineReturn) {
if (this.inlineReturnOpenBraces > 0) {
Expand Down Expand Up @@ -470,8 +475,8 @@ protected boolean commentParse() {
}
}
}
break;
}
break;
//$FALL-THROUGH$
case '/':
if (this.markdown) {
Expand Down Expand Up @@ -1393,6 +1398,40 @@ protected boolean parseReference() throws InvalidInputException {
return parseReference(false);
}

// Parses a complete URL reference starting from current position
protected boolean parseURLReference(int pos, boolean advanceEndPos) throws InvalidInputException {
char[]fullURL = null;
int firstTokenStartPos;
StringBuilder urlBuilder = new StringBuilder();
char c;
firstTokenStartPos = pos;
while (pos < this.source.length) {
c = this.source[pos];
if (c == '[') // invalid syntax for url
return false;
if (c == '(' || c == ' ') {
pos++;
continue;
}
if (c == '\n' || c == '\r' || c == ')') {
break;
}
urlBuilder.append(c);
pos++;
}
if (advanceEndPos)
this.index = pos;
fullURL = urlBuilder.toString().toCharArray();

this.identifierPtr = 0;
this.identifierStack[this.identifierPtr] = fullURL;
this.identifierPositionStack[this.identifierPtr] = (((long) firstTokenStartPos) << 32) + (pos - 1);
this.identifierLengthStack[this.identifierLengthPtr] = 1;
Object typeRef = createTypeReference(TerminalToken.TokenNameInvalid, true);
pushSeeRef(typeRef);
return true;
}

/*
* Parse a reference in @see tag
*/
Expand Down Expand Up @@ -3612,6 +3651,7 @@ protected boolean verifySpaceOrEndComment() {
// Whitespace or inline tag closing brace
char ch = peekChar();
switch (ch) {
case ')':
case ']':
// TODO: Check if we need to exclude escaped ]
if (this.markdown)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
// move it past '['
currentChar = readChar();
start = this.index;
} else if (peekChar() == '(') {
valid = parseURLReference(this.index, true);
} else {
break loop;
}
Expand All @@ -602,7 +604,8 @@ protected boolean parseMarkdownLinks(int previousPosition) throws InvalidInputEx
int eofBkup = this.scanner.eofPosition;
this.scanner.resetTo(start, Math.max(this.javadocEnd, this.index));
this.tagValue = TAG_LINK_VALUE;
valid = parseReference(true);
if (!valid)
valid = parseReference(true);
this.tagValue = NO_TAG_VALUE;
this.scanner.eofPosition = eofBkup;
this.markdownHelper.resetLineStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ protected TerminalToken getNextToken0() throws InvalidInputException {
}
isUnicode = false;
previous = this.currentPosition;
if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\')
if ((this.currentPosition < this.eofPosition && (this.currentCharacter = this.source[this.currentPosition++]) == '\\')
&& (this.source[this.currentPosition] == 'u')) {
//-------------unicode traitement ------------
getNextUnicodeChar();
Expand All @@ -1746,8 +1746,8 @@ protected TerminalToken getNextToken0() throws InvalidInputException {
//loop as long as lines start with ///
int firstTag = 0;
while(true) {
if (this.currentPosition > this.eofPosition) {
throw unterminatedComment();
if (this.currentPosition == this.eofPosition) {
break;
}
if ((this.currentCharacter == '\r') || (this.currentCharacter == '\n')) {
if (this.recordLineSeparator) {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.builder; singleton:=true
Bundle-Version: 3.12.1000.qualifier
Bundle-Version: 3.12.1100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.builder
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<relativePath>../tests-pom/</relativePath>
</parent>
<artifactId>org.eclipse.jdt.core.tests.builder</artifactId>
<version>3.12.1000-SNAPSHOT</version>
<version>3.12.1100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Loading
Loading