org.eclipse.jdt.core.compiler.CharOperation Java Examples

The following examples show how to use org.eclipse.jdt.core.compiler.CharOperation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerialVersionHashOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static int getClassModifiers(IClassFileReader cfReader) {
	IInnerClassesAttribute innerClassesAttribute= cfReader.getInnerClassesAttribute();
	if (innerClassesAttribute != null) {
		IInnerClassesAttributeEntry[] entries = innerClassesAttribute.getInnerClassAttributesEntries();
		for (int i= 0; i < entries.length; i++) {
			IInnerClassesAttributeEntry entry = entries[i];
			char[] innerClassName = entry.getInnerClassName();
			if (innerClassName != null) {
				if (CharOperation.equals(cfReader.getClassName(), innerClassName)) {
					return entry.getAccessFlags();
				}
			}
		}
	}
	return cfReader.getAccessFlags();
}
 
Example #2
Source File: TypeReferencePattern.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public TypeReferencePattern(char[] qualification, char[] simpleName, String typeSignature, int limitTo, char typeSuffix, int matchRule) {
	this(qualification, simpleName,matchRule);
	this.typeSuffix = typeSuffix;
	if (typeSignature != null) {
		// store type signatures and arguments
		this.typeSignatures = Util.splitTypeLevelsSignature(typeSignature);
		setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
		if (hasTypeArguments()) {
			this.segmentsSize = getTypeArguments().length + CharOperation.occurencesOf('/', this.typeSignatures[0]) - 1;
		}
	}
    this.fineGrain = limitTo & 0xFFFFFFF0;
    if (this.fineGrain == IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE) {
    	this.categories = CATEGORIES_ANNOT_REF;
    }
}
 
Example #3
Source File: CodeSnippetScope.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
	ReferenceBinding object = getJavaLangObject();
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
	if (methodBinding != null) {
		// handle the method clone() specially... cannot be protected or throw exceptions
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return methodBinding;
	}

	// answers closest approximation, may not check argumentTypes or visibility
	methodBinding = findMethod(object, selector, argumentTypes, invocationSite, false);
	if (methodBinding == null)
		return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
	if (methodBinding.isValidBinding()) {
	    MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite, Scope.FULL_INFERENCE);
	    if (compatibleMethod == null)
			return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
	    methodBinding = compatibleMethod;
		if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
			return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
	}
	return methodBinding;
}
 
Example #4
Source File: LookupEnvironment.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private PackageBinding computePackageFrom(char[][] constantPoolName, boolean isMissing) {
	if (constantPoolName.length == 1)
		return this.defaultPackage;

	PackageBinding packageBinding = getPackage0(constantPoolName[0]);
	if (packageBinding == null || packageBinding == TheNotFoundPackage) {
		packageBinding = new PackageBinding(constantPoolName[0], this);
		if (isMissing) packageBinding.tagBits |= TagBits.HasMissingType;
		this.knownPackages.put(constantPoolName[0], packageBinding);
	}

	for (int i = 1, length = constantPoolName.length - 1; i < length; i++) {
		PackageBinding parent = packageBinding;
		if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) {
			packageBinding = new PackageBinding(CharOperation.subarray(constantPoolName, 0, i + 1), parent, this);
			if (isMissing) {
				packageBinding.tagBits |= TagBits.HasMissingType;
			}
			parent.addPackage(packageBinding);
		}
	}
	return packageBinding;
}
 
Example #5
Source File: HierarchyResolver.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public ReferenceBinding setFocusType(char[][] compoundName) {
	if (compoundName == null || this.lookupEnvironment == null) return null;
	this.focusType = this.lookupEnvironment.getCachedType(compoundName);
	if (this.focusType == null) {
		this.focusType = this.lookupEnvironment.askForType(compoundName);
		if (this.focusType == null) {
			int length = compoundName.length;
			char[] typeName = compoundName[length-1];
			int firstDollar = CharOperation.indexOf('$', typeName);
			if (firstDollar != -1) {
				compoundName[length-1] = CharOperation.subarray(typeName, 0, firstDollar);
				this.focusType = this.lookupEnvironment.askForType(compoundName);
				if (this.focusType != null) {
					char[][] memberTypeNames = CharOperation.splitOn('$', typeName, firstDollar+1, typeName.length);
					for (int i = 0; i < memberTypeNames.length; i++) {
						this.focusType = this.focusType.getMemberType(memberTypeNames[i]);
						if (this.focusType == null)
							return null;
					}
				}
			}
		}
	}
	return this.focusType;
}
 
Example #6
Source File: UnresolvedReferenceNameFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void removeLocals(Statement[] statements, int start, int end) {
	if (statements != null) {
		for (int i = 0; i < statements.length; i++) {
			if (statements[i] instanceof LocalDeclaration) {
				LocalDeclaration localDeclaration = (LocalDeclaration) statements[i];
				int j = indexOfFisrtNameAfter(start);
				done : while (j != -1) {
					int nameStart = this.potentialVariableNameStarts[j];
					if (start <= nameStart && nameStart <= end) {
						if (CharOperation.equals(this.potentialVariableNames[j], localDeclaration.name, false)) {
							removeNameAt(j);
						}
					}

					if (end < nameStart) break done;
					j = indexOfNextName(j);
				}
			}
		}

	}
}
 
Example #7
Source File: SourceTypeBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public FieldBinding getSyntheticField(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) {
	if (!isPrototype()) throw new IllegalStateException();
	if (this.synthetics == null || this.synthetics[SourceTypeBinding.FIELD_EMUL] == null) return null;
	FieldBinding field = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get(targetEnclosingType);
	if (field != null) return field;

	// type compatibility : to handle cases such as
	// class T { class M{}}
	// class S extends T { class N extends M {}} --> need to use S as a default enclosing instance for the super constructor call in N().
	if (!onlyExactMatch){
		Iterator accessFields = this.synthetics[SourceTypeBinding.FIELD_EMUL].values().iterator();
		while (accessFields.hasNext()) {
			field = (FieldBinding) accessFields.next();
			if (CharOperation.prefixEquals(TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX, field.name)
				&& field.type.findSuperTypeOriginatingFrom(targetEnclosingType) != null)
					return field;
		}
	}
	return null;
}
 
Example #8
Source File: VariableElementImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean hides(Element hiddenElement)
{
	if (_binding instanceof FieldBinding) {
		if (!(((ElementImpl)hiddenElement)._binding instanceof FieldBinding)) {
			return false;
		}
		FieldBinding hidden = (FieldBinding)((ElementImpl)hiddenElement)._binding;
		if (hidden.isPrivate()) {
			return false;
		}
		FieldBinding hider = (FieldBinding)_binding;
		if (hidden == hider) {
			return false;
		}
		if (!CharOperation.equals(hider.name, hidden.name)) {
			return false;
		}
		return null != hider.declaringClass.findSuperTypeOriginatingFrom(hidden.declaringClass);
	}
	// TODO: should we implement hides() for method parameters?
	return false;
}
 
Example #9
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ICompilationUnit getCompilationUnit(char[] fileName, WorkingCopyOwner workingCopyOwner) {
	char[] slashSeparatedFileName = CharOperation.replaceOnCopy(fileName, File.separatorChar, '/');
	int pkgEnd = CharOperation.lastIndexOf('/', slashSeparatedFileName); // pkgEnd is exclusive
	if (pkgEnd == -1)
		return null;
	IPackageFragment pkg = getPackageFragment(slashSeparatedFileName, pkgEnd, -1/*no jar separator for .java files*/);
	if (pkg == null) return null;
	int start;
	ICompilationUnit cu = pkg.getCompilationUnit(new String(slashSeparatedFileName, start =  pkgEnd+1, slashSeparatedFileName.length - start));
	if (workingCopyOwner != null) {
		ICompilationUnit workingCopy = cu.findWorkingCopy(workingCopyOwner);
		if (workingCopy != null)
			return workingCopy;
	}
	return cu;
}
 
Example #10
Source File: BinaryIndexer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void addTypeReference(char[] typeName) {
	int length = typeName.length;
	if (length > 2 && typeName[length - 2] == '$') {
		switch (typeName[length - 1]) {
			case '0' :
			case '1' :
			case '2' :
			case '3' :
			case '4' :
			case '5' :
			case '6' :
			case '7' :
			case '8' :
			case '9' :
				return; // skip local type names
		}
	}

 	// consider that A$B is a member type: so replace '$' with '.'
 	// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=40116)
	typeName = CharOperation.replaceOnCopy(typeName, '$', '.'); // copy it so the original is not modified

	super.addTypeReference(typeName);
}
 
Example #11
Source File: LambdaFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static LambdaMethod createLambdaMethod(JavaElement parent, String selector, String key, int sourceStart, int sourceEnd, int arrowPosition, String [] parameterTypes, String [] parameterNames, String returnType) {
	SourceMethodInfo info = null;
	boolean isBinary = (parent instanceof BinaryLambdaExpression);
	info = new SourceMethodInfo();
	info.setSourceRangeStart(sourceStart);
	info.setSourceRangeEnd(sourceEnd);
	info.setFlags(0);
	info.setNameSourceStart(sourceStart);
	info.setNameSourceEnd(arrowPosition);
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
	int length;
	char[][] argumentNames = new char[length = parameterNames.length][];
	for (int i = 0; i < length; i++)
		argumentNames[i] = manager.intern(parameterNames[i].toCharArray());
	info.setArgumentNames(argumentNames);
	info.setReturnType(manager.intern(Signature.toCharArray(returnType.toCharArray())));
	info.setExceptionTypeNames(CharOperation.NO_CHAR_CHAR);
	info.arguments = null; // will be updated shortly, parent has to come into existence first.

	return isBinary ? new BinaryLambdaMethod(parent, selector, key, sourceStart, parameterTypes, parameterNames, returnType, info) : 
			new LambdaMethod(parent, selector, key, sourceStart, parameterTypes, parameterNames, returnType, info);
}
 
Example #12
Source File: PublicScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public final void setSource(char[] sourceString){
	//the source-buffer is set to sourceString

	int sourceLength;
	if (sourceString == null) {
		this.source = CharOperation.NO_CHAR;
		sourceLength = 0;
	} else {
		this.source = sourceString;
		sourceLength = sourceString.length;
	}
	this.startPosition = -1;
	this.eofPosition = sourceLength;
	this.initialPosition = this.currentPosition = 0;
	this.containsAssertKeyword = false;
	this.linePtr = -1;
}
 
Example #13
Source File: NamingConventions.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static char[] suggestNewName(char[] name, char[][] excludedNames){
	if(excludedNames == null) {
		return name;
	}

	char[] newName = name;
	int count = 2;
	int i = 0;
	while (i < excludedNames.length) {
		if(CharOperation.equals(newName, excludedNames[i], false)) {
			newName = CharOperation.concat(name, String.valueOf(count++).toCharArray());
			i = 0;
		} else {
			i++;
		}
	}
	return newName;
}
 
Example #14
Source File: LongLiteral.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static LongLiteral buildLongLiteral(char[] token, int s, int e) {
	// remove '_' and prefix '0' first
	char[] longReducedToken = removePrefixZerosAndUnderscores(token, true);
	switch(longReducedToken.length) {
		case 19 :
			// 0x8000000000000000L
			if (CharOperation.equals(longReducedToken, HEXA_MIN_VALUE)) {
				return new LongLiteralMinValue(token, longReducedToken != token ? longReducedToken : null, s, e);
			}
			break;
		case 24 :
			// 01000000000000000000000L
			if (CharOperation.equals(longReducedToken, OCTAL_MIN_VALUE)) {
				return new LongLiteralMinValue(token, longReducedToken != token ? longReducedToken : null, s, e);
			}
			break;
	}
	return new LongLiteral(token, longReducedToken != token ? longReducedToken : null, s, e);
}
 
Example #15
Source File: AnnotationAtttributeProposalInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Resolves the member described by the receiver and returns it if found.
 * Returns <code>null</code> if no corresponding member can be found.
 *
 * @return the resolved member or <code>null</code> if none is found
 * @throws JavaModelException if accessing the java model fails
 */
@Override
protected IMember resolveMember() throws JavaModelException {
	char[] declarationSignature= fProposal.getDeclarationSignature();
	// for synthetic fields on arrays, declaration signatures may be null
	// TODO remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
	if (declarationSignature == null)
		return null;
	String typeName= SignatureUtil.stripSignatureToFQN(String.valueOf(declarationSignature));
	IType type= fJavaProject.findType(typeName);
	if (type != null) {
		String name= String.valueOf(fProposal.getName());
		IMethod method= type.getMethod(name, CharOperation.NO_STRINGS);
		if (method.exists())
			return method;
	}
	return null;
}
 
Example #16
Source File: InternalNamingConventions.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
	char[] name = new char[]{firstName};

	for(int i = 0 ; i < excludedNames.length ; i++){
		if(CharOperation.equals(name, excludedNames[i], false)) {
			name[0]++;
			if(name[0] > 'z')
				name[0] = 'a';
			if(name[0] == firstName)
				return null;
			i = 0;
		}
	}

	return name;
}
 
Example #17
Source File: BinaryType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see IType#getTypeParameterSignatures()
 * @since 3.0
 */
public String[] getTypeParameterSignatures() throws JavaModelException {
	IBinaryType info = (IBinaryType) getElementInfo();
	char[] genericSignature = info.getGenericSignature();
	if (genericSignature == null)
		return CharOperation.NO_STRINGS;

	char[] dotBaseSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
	char[][] typeParams = Signature.getTypeParameters(dotBaseSignature);
	return CharOperation.toStrings(typeParams);
}
 
Example #18
Source File: Signature.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Extracts the type argument signatures from the given type signature.
 * Returns an empty array if the type signature is not a parameterized type signature.
 *
 * @param parameterizedTypeSignature the parameterized type signature
 * @return the signatures of the type arguments
 * @exception IllegalArgumentException if the signature is syntactically incorrect
 *
 * @since 3.1
 */
public static char[][] getTypeArguments(char[] parameterizedTypeSignature) throws IllegalArgumentException {
	int length = parameterizedTypeSignature.length;
	if (length < 2 || parameterizedTypeSignature[length-2] != C_GENERIC_END)
		// cannot have type arguments otherwise signature would end by ">;"
		return CharOperation.NO_CHAR_CHAR;
	int count = 1; // start to count generic end/start peers
	int start = length - 2;
	while (start >= 0 && count > 0) {
		switch (parameterizedTypeSignature[--start]) {
			case C_GENERIC_START:
				count--;
				break;
			case C_GENERIC_END:
				count++;
				break;
		}
	}
	if (start < 0) // invalid number of generic start/end
		throw new IllegalArgumentException();
	ArrayList args = new ArrayList();
	int p = start + 1;
	while (true) {
		if (p >= parameterizedTypeSignature.length) {
			throw new IllegalArgumentException();
		}
		char c = parameterizedTypeSignature[p];
		if (c == C_GENERIC_END) {
			int size = args.size();
			char[][] result = new char[size][];
			args.toArray(result);
			return result;
		}
		int e = Util.scanTypeArgumentSignature(parameterizedTypeSignature, p);
		args.add(CharOperation.subarray(parameterizedTypeSignature, p, e+1));
		p = e + 1;
	}
}
 
Example #19
Source File: SingleNameReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
 */
public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
	if (runtimeTimeType == null || compileTimeType == null)
		return;
	if ((this.bits & Binding.FIELD) != 0 && this.binding != null && this.binding.isValidBinding()) {
		// set the generic cast after the fact, once the type expectation is fully known (no need for strict cast)
		FieldBinding field = (FieldBinding) this.binding;
		FieldBinding originalBinding = field.original();
		TypeBinding originalType = originalBinding.type;
		// extra cast needed if field type is type variable
		if (originalType.leafComponentType().isTypeVariable()) {
	    	TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType())
	    		? compileTimeType  // unboxing: checkcast before conversion
	    		: runtimeTimeType;
	        this.genericCast = originalType.genericCast(scope.boxing(targetType));
	        if (this.genericCast instanceof ReferenceBinding) {
				ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast;
				if (!referenceCast.canBeSeenBy(scope)) {
		        	scope.problemReporter().invalidType(this,
		        			new ProblemReferenceBinding(
								CharOperation.splitOn('.', referenceCast.shortReadableName()),
								referenceCast,
								ProblemReasons.NotVisible));
				}
	        }
		}
	}
	super.computeConversion(scope, runtimeTimeType, compileTimeType);
}
 
Example #20
Source File: ReferenceCollection.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the fully-qualified type names of any new dependencies, each name is of the form "p1.p2.A.B".
 * 
 * @see BuildContext#recordDependencies(String[])
 */
public void addDependencies(Collection<String> typeNameDependencies) {
  // if each qualified type name is already known then all of its subNames can be skipped
  // and its expected that very few qualified names in typeNameDependencies need to be added
  // but could always take 'p1.p2.p3.X' and make all qualified names 'p1' 'p1.p2' 'p1.p2.p3' 'p1.p2.p3.X', then intern
  char[][][] qNames = new char[typeNameDependencies.size()][][];
  Iterator<String> typeNameDependency = typeNameDependencies.iterator();
  for (int i = 0; typeNameDependency.hasNext(); i++) {
    qNames[i] = CharOperation.splitOn('.', typeNameDependency.next().toCharArray());
  }
  qNames = internQualifiedNames(qNames, false);

  next: for (int i = qNames.length; --i >= 0;) {
    char[][] qualifiedTypeName = qNames[i];
    while (!includes(qualifiedTypeName)) {
      if (!includes(qualifiedTypeName[qualifiedTypeName.length - 1])) {
        this.simpleNameReferences.add(new String(qualifiedTypeName[qualifiedTypeName.length - 1]));
      }
      if (!insideRoot(qualifiedTypeName[0])) {
        this.rootReferences.add(new String(qualifiedTypeName[0]));
      }
      this.qualifiedNameReferences.add(CharOperation.toString(qualifiedTypeName));

      qualifiedTypeName = CharOperation.subarray(qualifiedTypeName, 0, qualifiedTypeName.length - 1);
      char[][][] temp = internQualifiedNames(new char[][][] {qualifiedTypeName}, false);
      if (temp == EmptyQualifiedNames) continue next; // qualifiedTypeName is a well known name
      qualifiedTypeName = temp[0];
    }
  }
}
 
Example #21
Source File: ConstructorPattern.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static char[] getTypeErasure(char[] typeName) {
	int index;
	if ((index = CharOperation.indexOf('<', typeName)) == -1) return typeName;
	
	int length = typeName.length;
	char[] typeErasurename = new char[length - 2];
	
	System.arraycopy(typeName, 0, typeErasurename, 0, index);
	
	int depth = 1;
	for (int i = index + 1; i < length; i++) {
		switch (typeName[i]) {
			case '<':
				depth++;
				break;
			case '>':
				depth--;
				break;
			default:
				if (depth == 0) {
					typeErasurename[index++] = typeName[i];
				}
				break;
		}
	}
	
	System.arraycopy(typeErasurename, 0, typeErasurename = new char[index], 0, index);
	return typeErasurename;
}
 
Example #22
Source File: CompletionElementNotifier.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
	char[][] interfaceNames = null;
	int superInterfacesLength = 0;
	TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
	if (superInterfaces != null) {
		superInterfacesLength = superInterfaces.length;
		interfaceNames = new char[superInterfacesLength][];
	} else {
		if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
			// see PR 3442
			QualifiedAllocationExpression alloc = typeDeclaration.allocation;
			if (alloc != null && alloc.type != null) {
				superInterfaces = new TypeReference[] { alloc.type};
				superInterfacesLength = 1;
				interfaceNames = new char[1][];
			}
		}
	}
	if (superInterfaces != null) {
		int superInterfaceCount = 0;
		next: for (int i = 0; i < superInterfacesLength; i++) {
			TypeReference superInterface = superInterfaces[i];

			if (superInterface instanceof CompletionOnKeyword) continue next;
			if (CompletionUnitStructureRequestor.hasEmptyName(superInterface, this.assistNode)) continue next;

			interfaceNames[superInterfaceCount++] = CharOperation.concatWith(superInterface.getParameterizedTypeName(), '.');
		}

		if (superInterfaceCount == 0) return null;
		if (superInterfaceCount < superInterfacesLength) {
			System.arraycopy(interfaceNames, 0, interfaceNames = new char[superInterfaceCount][], 0, superInterfaceCount);
		}
	}
	return interfaceNames;
}
 
Example #23
Source File: CompletionElementNotifier.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected char[] getSuperclassName(TypeDeclaration typeDeclaration) {
	TypeReference superclass = typeDeclaration.superclass;

	if (superclass instanceof CompletionOnKeyword) return null;
	if (CompletionUnitStructureRequestor.hasEmptyName(superclass, this.assistNode)) return null;

	return superclass != null ? CharOperation.concatWith(superclass.getParameterizedTypeName(), '.') : null;
}
 
Example #24
Source File: SelectionOnFieldType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public SelectionOnFieldType(TypeReference type) {
	super();
	this.sourceStart = type.sourceStart;
	this.sourceEnd = type.sourceEnd;
	this.type = type;
	this.name = CharOperation.NO_CHAR;
}
 
Example #25
Source File: SimpleDOMBuilder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 */
public void enterField(FieldInfo fieldInfo) {

	int[] sourceRange = {fieldInfo.declarationStart, -1};
	int[] nameRange = {fieldInfo.nameSourceStart, fieldInfo.nameSourceEnd};
	boolean isSecondary= false;
	if (this.fNode instanceof DOMField) {
		isSecondary = fieldInfo.declarationStart == this.fNode.fSourceRange[0];
	}
	this.fNode = new DOMField(this.fDocument, sourceRange, CharOperation.charToString(fieldInfo.name), nameRange,
		fieldInfo.modifiers, CharOperation.charToString(fieldInfo.type), isSecondary);
	addChild(this.fNode);
	this.fStack.push(this.fNode);
}
 
Example #26
Source File: ClassFileWorkingCopy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public char[] getContents() {
	try {
		IBuffer buffer = getBuffer();
		if (buffer == null) return CharOperation.NO_CHAR;
		char[] characters = buffer.getCharacters();
		if (characters == null) return CharOperation.NO_CHAR;
		return characters;
	} catch (JavaModelException e) {
		return CharOperation.NO_CHAR;
	}
}
 
Example #27
Source File: ArrayBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Answer the receiver's constant pool name.
 * NOTE: This method should only be used during/after code gen.
 * e.g. '[Ljava/lang/Object;'
 */
public char[] constantPoolName() {
	if (this.constantPoolName != null)
		return this.constantPoolName;

	char[] brackets = new char[this.dimensions];
	for (int i = this.dimensions - 1; i >= 0; i--) brackets[i] = '[';
	return this.constantPoolName = CharOperation.concat(brackets, this.leafComponentType.signature());
}
 
Example #28
Source File: SimpleSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Object add(char[] object) {
	int length = this.values.length;
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
	char[] current;
	while ((current = this.values[index]) != null) {
		if (CharOperation.equals(current, object)) return this.values[index] = object;
		if (++index == length) index = 0;
	}
	this.values[index] = object;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold) rehash();
	return object;
}
 
Example #29
Source File: DOMMember.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the String to be used for this member's flags when
 * generating contents - either the original contents in the document
 * or the replacement value.
 */
protected char[] getModifiersText() {
	if (this.fModifiers == null) {
		if (this.fModifierRange[0] < 0) {
			return null;
		} else {
			return CharOperation.subarray(this.fDocument, this.fModifierRange[0], this.fModifierRange[1] + 1);
		}
	} else {
		return this.fModifiers;
	}
}
 
Example #30
Source File: ClasspathJar.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public char[][][] findTypeNames(String qualifiedPackageName) {
	if (!isPackage(qualifiedPackageName))
		return null; // most common case

	ArrayList answers = new ArrayList();
	nextEntry : for (Enumeration e = this.zipFile.entries(); e.hasMoreElements(); ) {
		String fileName = ((ZipEntry) e.nextElement()).getName();

		// add the package name & all of its parent packages
		int last = fileName.lastIndexOf('/');
		while (last > 0) {
			// extract the package name
			String packageName = fileName.substring(0, last);
			if (!qualifiedPackageName.equals(packageName))
				continue nextEntry;
			int indexOfDot = fileName.lastIndexOf('.');
			if (indexOfDot != -1) {
				String typeName = fileName.substring(last + 1, indexOfDot);
				char[] packageArray = packageName.toCharArray();
				answers.add(
					CharOperation.arrayConcat(
						CharOperation.splitOn('/', packageArray),
						typeName.toCharArray()));
			}
		}
	}
	int size = answers.size();
	if (size != 0) {
		char[][][] result = new char[size][][];
		answers.toArray(result);
		return null;
	}
	return null;
}