private void sortModuleDeclarationsFirst(ICompilationUnit[] sourceUnits) { Arrays.sort(sourceUnits, (u1, u2) -> { char[] fn1 = u1.getFileName(); char[] fn2 = u2.getFileName(); boolean isMod1 = CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_CLASS_NAME); boolean isMod2 = CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_CLASS_NAME); if (isMod1 == isMod2) { return 0; } return isMod1 ? -1 : 1; }); }
for (CompilationUnit compilationUnit : this.compilationUnits) { char[] charName = compilationUnit.getFileName(); boolean isModuleInfo = CharOperation.endsWith(charName, TypeConstants.MODULE_INFO_FILE_NAME); if (isModuleInfo == (round == 0)) { // 1st round: modules, 2nd round others (to ensure populating pathToModCU well in time)
private void sortModuleDeclarationsFirst(ICompilationUnit[] sourceUnits) { Arrays.sort(sourceUnits, (u1, u2) -> { char[] fn1 = u1.getFileName(); char[] fn2 = u2.getFileName(); boolean isMod1 = CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_CLASS_NAME); boolean isMod2 = CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_CLASS_NAME); if (isMod1 == isMod2) return 0; return isMod1 ? -1 : 1; }); }
private void sortModuleDeclarationsFirst(ICompilationUnit[] sourceUnits) { Arrays.sort(sourceUnits, (u1, u2) -> { char[] fn1 = u1.getFileName(); char[] fn2 = u2.getFileName(); boolean isMod1 = CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_CLASS_NAME); boolean isMod2 = CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_CLASS_NAME); if (isMod1 == isMod2) return 0; return isMod1 ? -1 : 1; }); }
private void sortModuleDeclarationsFirst(ICompilationUnit[] sourceUnits) { Arrays.sort(sourceUnits, (u1, u2) -> { char[] fn1 = u1.getFileName(); char[] fn2 = u2.getFileName(); boolean isMod1 = CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn1, TypeConstants.MODULE_INFO_CLASS_NAME); boolean isMod2 = CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_FILE_NAME) || CharOperation.endsWith(fn2, TypeConstants.MODULE_INFO_CLASS_NAME); if (isMod1 == isMod2) return 0; return isMod1 ? -1 : 1; }); }
@Override public ModuleBinding module(LookupEnvironment rootEnvironment) { if (this.moduleBinding != null) return this.moduleBinding; if (this.modCU != null) return this.moduleBinding = this.modCU.module(rootEnvironment); if (CharOperation.endsWith(this.fileName, TypeConstants.MODULE_INFO_FILE_NAME)) { this.moduleBinding = rootEnvironment.getModule(this.module); if (this.moduleBinding == null) throw new IllegalStateException("Module should be known"); //$NON-NLS-1$ return this.moduleBinding; } return rootEnvironment.UnNamedModule; } public String getDestinationPath() {
@Override public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
protected boolean matches(char[][] compoundName) { int length = compoundName.length; if (length == 0) return false; char[] simpleName = compoundName[length-1]; int last = length - 1; if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) { // most frequent case: simple name equals last segment of compoundName char[][] qualification = new char[last][]; System.arraycopy(compoundName, 0, qualification, 0, last); return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.')); } if (!CharOperation.endsWith(simpleName, this.typeSimpleName)) return false; // member type -> transform A.B.C$D into A.B.C.D System.arraycopy(compoundName, 0, compoundName = new char[length+1][], 0, last); int dollar = CharOperation.indexOf('$', simpleName); if (dollar == -1) return false; compoundName[last] = CharOperation.subarray(simpleName, 0, dollar); compoundName[length] = CharOperation.subarray(simpleName, dollar+1, simpleName.length); return this.matches(compoundName); } protected boolean matches(ReferenceBinding binding) {
private boolean isForbiddenType(char[] givenPkgName, char[] givenTypeName, char[][] enclosingTypeNames) { // CharOperation.concatWith() handles the cases where input args are null/empty char[] fullTypeName = CharOperation.concatWith(enclosingTypeNames, givenTypeName, '.'); for (int i = 0; i <= this.forbbidenBindingsPtr; i++) { if (this.forbbidenBindings[i] instanceof TypeBinding) { TypeBinding typeBinding = (TypeBinding) this.forbbidenBindings[i]; char[] currPkgName = typeBinding.qualifiedPackageName(); if (CharOperation.equals(givenPkgName, currPkgName)) { char[] currTypeName = typeBinding.qualifiedSourceName(); if (CharOperation.equals(fullTypeName, currTypeName)) { return true; } } } } // filter packages ending with enum for projects above 1.5 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=317264 if (this.compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5 && CharOperation.endsWith(givenPkgName, DOT_ENUM)) { //note: it should be .enum and not just enum return true; } return false; }
private void findModuleName(CompilationUnitDeclaration parsedUnit) { char[] fileName1 = parsedUnit.getFileName(); if (fileName1 == null || !CharOperation.endsWith(fileName1, MODULE_INFO_FILE_NAME)) return; int lastFileSeparatorIndex = fileName1.length - (MODULE_INFO_FILE_NAME.length + 1); if (lastFileSeparatorIndex <= 0) return; int prevFileSeparatorIndex = CharOperation.lastIndexOf(fileName1[lastFileSeparatorIndex], fileName1, 0, lastFileSeparatorIndex - 1); prevFileSeparatorIndex = prevFileSeparatorIndex < 0 ? 0 : prevFileSeparatorIndex + 1; char[] moduleName = CharOperation.subarray(fileName1, prevFileSeparatorIndex, lastFileSeparatorIndex); if (moduleName == null || moduleName.length == 0) return; this.completionToken = CharOperation.concatWith(this.moduleDeclaration.tokens, '.'); if (this.completionToken.length > 0 && !CharOperation.prefixEquals(this.completionToken, moduleName)) return; InternalCompletionProposal proposal = createProposal(CompletionProposal.MODULE_DECLARATION, this.actualCompletionPosition); proposal.setName(moduleName); proposal.setCompletion(moduleName); proposal.setReplaceRange((this.startPosition < 0) ? 0 : this.startPosition - this.offset, this.endPosition - this.offset); proposal.setTokenRange((this.tokenStart < 0) ? 0 : this.tokenStart - this.offset, this.tokenEnd - this.offset); proposal.setRelevance(R_MODULE_DECLARATION); this.requestor.accept(proposal); if(DEBUG) { this.printDebug(proposal); } }