final int stringLiteralsLength = this.stringLiteralsPtr;
final int nlsTagsLength = this.nlsTags == null ? 0 : this.nlsTags.length;
if (stringLiteralsLength == 0) {
if (nlsTagsLength != 0) {
for (int i = 0; i < nlsTagsLength; i++) {
NLSTag tag = this.nlsTags[i];
if (tag != null) {
this.scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
}
}
}
} else if (nlsTagsLength == 0) {
// resize string literals
if (this.stringLiterals.length != stringLiteralsLength) {
System.arraycopy(this.stringLiterals, 0, (this.stringLiterals = new StringLiteral[stringLiteralsLength]), 0, stringLiteralsLength);
}
Arrays.sort(this.stringLiterals, STRING_LITERAL_COMPARATOR);
for (int i = 0; i < stringLiteralsLength; i++) {
this.scope.problemReporter().nonExternalizedStringLiteral(this.stringLiterals[i]);
}
} else {
// need to iterate both arrays to find non matching elements
if (this.stringLiterals.length != stringLiteralsLength) {
System.arraycopy(this.stringLiterals, 0, (this.stringLiterals = new StringLiteral[stringLiteralsLength]), 0, stringLiteralsLength);
}
Arrays.sort(this.stringLiterals, STRING_LITERAL_COMPARATOR);
int indexInLine = 1;
int lastLineNumber = -1;
StringLiteral literal = null;
int index = 0;
int i = 0;
stringLiteralsLoop: for (; i < stringLiteralsLength; i++) {
literal = this.stringLiterals[i];
final int literalLineNumber = literal.lineNumber;
if (lastLineNumber != literalLineNumber) {
indexInLine = 1;
lastLineNumber = literalLineNumber;
} else {
indexInLine++;
}
if (index < nlsTagsLength) {
nlsTagsLoop: for (; index < nlsTagsLength; index++) {
NLSTag tag = this.nlsTags[index];
if (tag == null) continue nlsTagsLoop;
int tagLineNumber = tag.lineNumber;
if (literalLineNumber < tagLineNumber) {
this.scope.problemReporter().nonExternalizedStringLiteral(literal);
continue stringLiteralsLoop;
} else if (literalLineNumber == tagLineNumber) {
if (tag.index == indexInLine) {
this.nlsTags[index] = null;
index++;
continue stringLiteralsLoop;
} else {
nlsTagsLoop2: for (int index2 = index + 1; index2 < nlsTagsLength; index2++) {
NLSTag tag2 = this.nlsTags[index2];
if (tag2 == null) continue nlsTagsLoop2;
int tagLineNumber2 = tag2.lineNumber;
if (literalLineNumber == tagLineNumber2) {
if (tag2.index == indexInLine) {
this.nlsTags[index2] = null;
continue stringLiteralsLoop;
} else {
continue nlsTagsLoop2;
}
} else {
this.scope.problemReporter().nonExternalizedStringLiteral(literal);
continue stringLiteralsLoop;
}
}
this.scope.problemReporter().nonExternalizedStringLiteral(literal);
continue stringLiteralsLoop;
}
} else {
this.scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
continue nlsTagsLoop;
}
}
}
// all nls tags have been processed, so remaining string literals are not externalized
break stringLiteralsLoop;
}
for (; i < stringLiteralsLength; i++) {
this.scope.problemReporter().nonExternalizedStringLiteral(this.stringLiterals[i]);
}
if (index < nlsTagsLength) {
for (; index < nlsTagsLength; index++) {
NLSTag tag = this.nlsTags[index];
if (tag != null) {
this.scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
}
}
}