Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#equals()

The following examples show how to use org.eclipse.jdt.core.compiler.CharOperation#equals() . 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: MethodInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void decodeCodeAttribute(int offset) {
	int readOffset = offset + 10;
	int codeLength = (int) u4At(readOffset);
	readOffset += (4 + codeLength);
	int exceptionTableLength = u2At(readOffset);
	readOffset += 2;
	if (exceptionTableLength != 0) {
		for (int i = 0; i < exceptionTableLength; i++) {
			readOffset += 8;
		}
	}
	int attributesCount = u2At(readOffset);
	readOffset += 2;
	for (int i = 0; i < attributesCount; i++) {
		int utf8Offset = this.constantPoolOffsets[u2At(readOffset)] - this.structOffset;
		char[] attributeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
		if (CharOperation.equals(attributeName, AttributeNamesConstants.LocalVariableTableName)) {
			decodeLocalVariableAttribute(readOffset, codeLength);
		}
		readOffset += (6 + u4At(readOffset + 2));
	}
}
 
Example 2
Source File: HashtableOfPackage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public PackageBinding put(char[] key, PackageBinding value) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index] = value;
		if (++index == length) {
			index = 0;
		}
	}
	this.keyTable[index] = key;
	this.valueTable[index] = value;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();
	return value;
}
 
Example 3
Source File: BindingKeyResolver.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private TypeBinding getTypeBinding(char[] simpleTypeName) {
	if (this.typeBinding instanceof ReferenceBinding) {
		return ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName);
	}
	TypeDeclaration[] typeDeclarations =
		this.typeDeclaration == null ?
			(this.parsedUnit == null ? null : this.parsedUnit.types) :
			this.typeDeclaration.memberTypes;
	if (typeDeclarations == null) return null;
	for (int i = 0, length = typeDeclarations.length; i < length; i++) {
		TypeDeclaration declaration = typeDeclarations[i];
		if (CharOperation.equals(simpleTypeName, declaration.name)) {
			this.typeDeclaration = declaration;
			return declaration.binding;
		}
	}
	return null;
}
 
Example 4
Source File: HashtableOfType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ReferenceBinding get(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index];
		if (++index == length) {
			index = 0;
		}
	}
	return null;
}
 
Example 5
Source File: IntLiteral.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public IntLiteral convertToMinValue() {
	if (((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
		return this;
	}
	char[] token = this.reducedForm != null ? this.reducedForm : this.source;
	switch(token.length) {
		case 10 :
			// 2147483648
			if (CharOperation.equals(token, DECIMAL_MIN_VALUE)) {
				return new IntLiteralMinValue(this.source, this.reducedForm, this.sourceStart, this.sourceEnd);
			}
			break;
	}
	return this;
}
 
Example 6
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static IClassFileAttribute getAttribute(IMethodInfo methodInfo, char[] attributeName) {
	IClassFileAttribute[] attributes = methodInfo.getAttributes();
	for (int i = 0, max = attributes.length; i < max; i++) {
		if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) {
			return attributes[i];
		}
	}
	return null;
}
 
Example 7
Source File: Scribe.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void setEditsEnabled(int count) {
	for (int i=0; i<count; i++) {
		if (this.disablingTag != null && CharOperation.equals(this.scanner.foundTaskTags[i], this.disablingTag)) {
			this.editsEnabled = false;
		}
		if (this.enablingTag != null && CharOperation.equals(this.scanner.foundTaskTags[i], this.enablingTag)) {
			this.editsEnabled = true;
		}
	}
}
 
Example 8
Source File: LongLiteral.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public LongLiteral convertToMinValue() {
	if (((this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
		return this;
	}
	char[] token = this.reducedForm != null ? this.reducedForm : this.source;
	switch(token.length) {
		case 20 :
			// 9223372036854775808L
			if (CharOperation.equals(token, DECIMAL_MIN_VALUE, false)) {
				return new LongLiteralMinValue(this.source, this.reducedForm, this.sourceStart, this.sourceEnd);
			}
			break;
	}
	return this;
}
 
Example 9
Source File: ClassFileReader.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean hasStructuralMethodChanges(MethodInfo currentMethodInfo, MethodInfo otherMethodInfo) {
	// generic signature
	if (!CharOperation.equals(currentMethodInfo.getGenericSignature(), otherMethodInfo.getGenericSignature()))
		return true;
	if (currentMethodInfo.getModifiers() != otherMethodInfo.getModifiers())
		return true;
	if ((currentMethodInfo.getTagBits() & TagBits.AnnotationDeprecated) != (otherMethodInfo.getTagBits() & TagBits.AnnotationDeprecated))
		return true;
	if (hasStructuralAnnotationChanges(currentMethodInfo.getAnnotations(), otherMethodInfo.getAnnotations()))
		return true;
	// parameter annotations:
	int currentAnnotatedParamsCount = currentMethodInfo.getAnnotatedParametersCount();
	int otherAnnotatedParamsCount = otherMethodInfo.getAnnotatedParametersCount();
	if (currentAnnotatedParamsCount != otherAnnotatedParamsCount)
		return true;
	for (int i=0; i<currentAnnotatedParamsCount; i++) {
		if (hasStructuralAnnotationChanges(currentMethodInfo.getParameterAnnotations(i), otherMethodInfo.getParameterAnnotations(i)))
			return true;
	}

	if (!CharOperation.equals(currentMethodInfo.getSelector(), otherMethodInfo.getSelector()))
		return true;
	if (!CharOperation.equals(currentMethodInfo.getMethodDescriptor(), otherMethodInfo.getMethodDescriptor()))
		return true;
	if (!CharOperation.equals(currentMethodInfo.getGenericSignature(), otherMethodInfo.getGenericSignature()))
		return true;

	char[][] currentThrownExceptions = currentMethodInfo.getExceptionTypeNames();
	char[][] otherThrownExceptions = otherMethodInfo.getExceptionTypeNames();
	if (currentThrownExceptions != otherThrownExceptions) { // TypeConstants.NoExceptions
		int currentThrownExceptionsLength = currentThrownExceptions == null ? 0 : currentThrownExceptions.length;
		int otherThrownExceptionsLength = otherThrownExceptions == null ? 0 : otherThrownExceptions.length;
		if (currentThrownExceptionsLength != otherThrownExceptionsLength)
			return true;
		for (int k = 0; k < currentThrownExceptionsLength; k++)
			if (!CharOperation.equals(currentThrownExceptions[k], otherThrownExceptions[k]))
				return true;
	}
	return false;
}
 
Example 10
Source File: FieldReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean isEquivalent(Reference reference) {
	// only consider field references relative to "this":
	if (this.receiver.isThis() && !(this.receiver instanceof QualifiedThisReference)) {
		// current is a simple "this.f1"
		char[] otherToken = null;
		// matching 'reference' could be "f1" or "this.f1":
		if (reference instanceof SingleNameReference) {
			otherToken = ((SingleNameReference) reference).token;
		} else if (reference instanceof FieldReference) {
			FieldReference fr = (FieldReference) reference;
			if (fr.receiver.isThis() && !(fr.receiver instanceof QualifiedThisReference)) {
				otherToken = fr.token;
			}		
		}
		return otherToken != null && CharOperation.equals(this.token, otherToken);
	} else {
		// search deeper for "this" inside:
		char[][] thisTokens = getThisFieldTokens(1);
		if (thisTokens == null) {
			return false;
		}
		// other can be "this.f1.f2", too, or "f1.f2":
		char[][] otherTokens = null;
		if (reference instanceof FieldReference) {
			otherTokens = ((FieldReference) reference).getThisFieldTokens(1);
		} else if (reference instanceof QualifiedNameReference) {
			if (((QualifiedNameReference)reference).binding instanceof LocalVariableBinding)
				return false; // initial variable mismatch: local (from f1.f2) vs. field (from this.f1.f2)
			otherTokens = ((QualifiedNameReference) reference).tokens;
		}
		return CharOperation.equals(thisTokens, otherTokens);
	}
}
 
Example 11
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static IClassFileAttribute getAttribute(IFieldInfo fieldInfo, char[] attributeName) {
	IClassFileAttribute[] attributes = fieldInfo.getAttributes();
	for (int i = 0, max = attributes.length; i < max; i++) {
		if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) {
			return attributes[i];
		}
	}
	return null;
}
 
Example 12
Source File: VerificationTypeInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean equals(Object obj) {
	if (obj instanceof VerificationTypeInfo) {
		VerificationTypeInfo info1 = (VerificationTypeInfo) obj;
		return info1.tag == this.tag && CharOperation.equals(info1.constantPoolName(), constantPoolName());
	}
	return false;
}
 
Example 13
Source File: CompilationResult.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Same as getProblems() but don't answer problems that actually concern the enclosing package.
 */
public CategorizedProblem[] getCUProblems() {
	// Re-adjust the size of the problems if necessary and filter package problems
	if (this.problems != null) {
		CategorizedProblem[] filteredProblems = new CategorizedProblem[this.problemCount];
		int keep = 0;
		for (int i=0; i< this.problemCount; i++) {
			CategorizedProblem problem = this.problems[i];
			if (problem.getID() != IProblem.MissingNonNullByDefaultAnnotationOnPackage) {
				filteredProblems[keep++] = problem;
			} else if (this.compilationUnit != null) {
				if (CharOperation.equals(this.compilationUnit.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
					filteredProblems[keep++] = problem;
				}
			}
		}
		if (keep < this.problemCount) {
			System.arraycopy(filteredProblems, 0, filteredProblems = new CategorizedProblem[keep], 0, keep);
			this.problemCount = keep;
		}
		this.problems = filteredProblems;
		if (this.maxProblemPerUnit > 0 && this.problemCount > this.maxProblemPerUnit){
			quickPrioritize(this.problems, 0, this.problemCount - 1);
			this.problemCount = this.maxProblemPerUnit;
			System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount]), 0, this.problemCount);
		}

		// Stable sort problems per source positions.
		Arrays.sort(this.problems, 0, this.problems.length, CompilationResult.PROBLEM_COMPARATOR);
		//quickSort(problems, 0, problems.length-1);
	}
	return this.problems;
}
 
Example 14
Source File: MethodInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void decodeLocalVariableAttribute(int offset, int codeLength) {
	int readOffset = offset + 6;
	final int length = u2At(readOffset);
	if (length != 0) {
		readOffset += 2;
		this.argumentNames = new char[length][];
		int argumentNamesIndex = 0;
		for (int i = 0; i < length; i++) {
			int startPC = u2At(readOffset);
			if (startPC == 0) {
				int nameIndex = u2At(4 + readOffset);
				int utf8Offset = this.constantPoolOffsets[nameIndex] - this.structOffset;
				char[] localVariableName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
				if (!CharOperation.equals(localVariableName, ConstantPool.This)) {
					this.argumentNames[argumentNamesIndex++] = localVariableName;
				}
			} else {
				break;
			}
			readOffset += 10;
		}
		if (argumentNamesIndex != this.argumentNames.length) {
			// resize
			System.arraycopy(this.argumentNames, 0, (this.argumentNames = new char[argumentNamesIndex][]), 0, argumentNamesIndex);
		}
	}
}
 
Example 15
Source File: Annotation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void checkContainerAnnotationType(ASTNode culpritNode, BlockScope scope, ReferenceBinding containerAnnotationType, ReferenceBinding repeatableAnnotationType, boolean useSite) {
	MethodBinding[] annotationMethods = containerAnnotationType.methods();
	boolean sawValue = false;
	for (int i = 0, length = annotationMethods.length; i < length; ++i) {
		MethodBinding method = annotationMethods[i];
		if (CharOperation.equals(method.selector, TypeConstants.VALUE)) {
			sawValue = true;
			if (method.returnType.isArrayType() && method.returnType.dimensions() == 1) {
				ArrayBinding array = (ArrayBinding) method.returnType;
				if (TypeBinding.equalsEquals(array.elementsType(), repeatableAnnotationType)) continue;
			}
			repeatableAnnotationType.tagAsHavingDefectiveContainerType();
			scope.problemReporter().containerAnnotationTypeHasWrongValueType(culpritNode, containerAnnotationType, repeatableAnnotationType, method.returnType);
		} else {
			// Not the value() - must have default (or else isn't suitable as container)
			if ((method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0) {
				repeatableAnnotationType.tagAsHavingDefectiveContainerType();
				scope.problemReporter().containerAnnotationTypeHasNonDefaultMembers(culpritNode, containerAnnotationType, method.selector);
			}
		}
	}
	if (!sawValue) {
		repeatableAnnotationType.tagAsHavingDefectiveContainerType();
		scope.problemReporter().containerAnnotationTypeMustHaveValue(culpritNode, containerAnnotationType);
	}

	if (useSite)
		checkContainingAnnotationTargetAtUse((Annotation) culpritNode, scope, containerAnnotationType, repeatableAnnotationType);
	else 
		checkContainerAnnotationTypeTarget(culpritNode, scope, containerAnnotationType, repeatableAnnotationType);
	
	long annotationTypeBits = getAnnotationRetention(repeatableAnnotationType);
	long containerTypeBits = getAnnotationRetention(containerAnnotationType); 
	// Due to clever layout of the bits, we can compare the absolute value directly
	if (containerTypeBits < annotationTypeBits) {
		repeatableAnnotationType.tagAsHavingDefectiveContainerType();
		scope.problemReporter().containerAnnotationTypeHasShorterRetention(culpritNode, repeatableAnnotationType, getRetentionName(annotationTypeBits), containerAnnotationType, getRetentionName(containerTypeBits));
	}
	
	if ((repeatableAnnotationType.getAnnotationTagBits() & TagBits.AnnotationDocumented) != 0 && (containerAnnotationType.getAnnotationTagBits() & TagBits.AnnotationDocumented) == 0) {
		repeatableAnnotationType.tagAsHavingDefectiveContainerType();
		scope.problemReporter().repeatableAnnotationTypeIsDocumented(culpritNode, repeatableAnnotationType, containerAnnotationType);
	}
	
	if ((repeatableAnnotationType.getAnnotationTagBits() & TagBits.AnnotationInherited) != 0 && (containerAnnotationType.getAnnotationTagBits() & TagBits.AnnotationInherited) == 0) {
		repeatableAnnotationType.tagAsHavingDefectiveContainerType();
		scope.problemReporter().repeatableAnnotationTypeIsInherited(culpritNode, repeatableAnnotationType, containerAnnotationType);
	}
}
 
Example 16
Source File: FieldLocator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected void reportDeclaration(FieldBinding fieldBinding, MatchLocator locator, SimpleSet knownFields) throws CoreException {
	// ignore length field
	if (fieldBinding == ArrayBinding.ArrayLength) return;

	ReferenceBinding declaringClass = fieldBinding.declaringClass;
	IType type = locator.lookupType(declaringClass);
	if (type == null) return; // case of a secondary type

	char[] bindingName = fieldBinding.name;
	IField field = type.getField(new String(bindingName));
	if (knownFields.addIfNotIncluded(field) == null) return;

	IResource resource = type.getResource();
	boolean isBinary = type.isBinary();
	IBinaryType info = null;
	if (isBinary) {
		if (resource == null)
			resource = type.getJavaProject().getProject();
		info = locator.getBinaryInfo((org.eclipse.jdt.internal.core.ClassFile) type.getClassFile(), resource);
		locator.reportBinaryMemberDeclaration(resource, field, fieldBinding, info, SearchMatch.A_ACCURATE);
	} else {
		if (declaringClass instanceof ParameterizedTypeBinding)
			declaringClass = ((ParameterizedTypeBinding) declaringClass).genericType();
		ClassScope scope = ((SourceTypeBinding) declaringClass).scope;
		if (scope != null) {
			TypeDeclaration typeDecl = scope.referenceContext;
			FieldDeclaration fieldDecl = null;
			FieldDeclaration[] fieldDecls = typeDecl.fields;
			int length = fieldDecls == null ? 0 : fieldDecls.length;
			for (int i = 0; i < length; i++) {
				if (CharOperation.equals(bindingName, fieldDecls[i].name)) {
					fieldDecl = fieldDecls[i];
					break;
				}
			}
			if (fieldDecl != null) {
				int offset = fieldDecl.sourceStart;
				this.match = new FieldDeclarationMatch(((JavaElement) field).resolved(fieldBinding), SearchMatch.A_ACCURATE, offset, fieldDecl.sourceEnd-offset+1, locator.getParticipant(), resource);
				locator.report(this.match);
			}
		}
	}
}
 
Example 17
Source File: TypesImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
    public TypeMirror asMemberOf(DeclaredType containing, Element element) {
//        throw new UnsupportedOperationException("NYI: TypesImpl.asMemberOf(" + containing + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    	ElementImpl elementImpl = (ElementImpl) element;
    	DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
    	ReferenceBinding referenceBinding = (ReferenceBinding) declaredTypeImpl._binding;
    	switch(element.getKind()) {
    		case CONSTRUCTOR :
    		case METHOD :
    			MethodBinding methodBinding = (MethodBinding) elementImpl._binding;
    			if (TypeBinding.notEquals(methodBinding.declaringClass, referenceBinding)) {
    				throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
    			}
    			for (MethodBinding method : referenceBinding.methods()) {
    				if (CharOperation.equals(method.selector, methodBinding.selector)
    						&& method.areParameterErasuresEqual(methodBinding)) {
    					return this._env.getFactory().newTypeMirror(method);
    				}
    			}
    			break;
    		case FIELD :
    		case ENUM_CONSTANT:
    			FieldBinding fieldBinding = (FieldBinding) elementImpl._binding;
    			if (TypeBinding.notEquals(fieldBinding.declaringClass, referenceBinding)) {
    				throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
    			}
    			for (FieldBinding field : referenceBinding.fields()) {
    				if (CharOperation.equals(field.name, fieldBinding.name)) {
    					return this._env.getFactory().newTypeMirror(field);
    				}
    			}
    			break;
    		case ENUM :
    		case ANNOTATION_TYPE :
    		case INTERFACE :
    		case CLASS :
    			ReferenceBinding referenceBinding2 = (ReferenceBinding) elementImpl._binding;
    			if (TypeBinding.notEquals(referenceBinding2.enclosingType(), referenceBinding)) {
    				throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
    			}
    			for (ReferenceBinding referenceBinding3 : referenceBinding.memberTypes()) {
    				if (CharOperation.equals(referenceBinding3.compoundName, referenceBinding3.compoundName)) {
    					return this._env.getFactory().newTypeMirror(referenceBinding3);
    				}
    			}
    			break;
    		default:
    			break;
    	}
		throw new IllegalArgumentException("element is not valid for the containing declared type: element kind " + element.getKind()); //$NON-NLS-1$
    }
 
Example 18
Source File: TypeReferenceLocator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
void matchReportReference(Expression expr, int lastIndex, TypeBinding refBinding, MatchLocator locator) throws CoreException {

	// Look if there's a need to special report for parameterized type
	if (refBinding.isParameterizedType() || refBinding.isRawType()) {

		// Try to refine accuracy
		ParameterizedTypeBinding parameterizedBinding = (ParameterizedTypeBinding)refBinding;
		updateMatch(parameterizedBinding, this.pattern.getTypeArguments(), this.pattern.hasTypeParameters(), 0, locator);

		// See whether it is necessary to report or not
		if (this.match.getRule() == 0) return; // impossible match
		boolean report = (this.isErasureMatch && this.match.isErasure()) || (this.isEquivalentMatch && this.match.isEquivalent()) || this.match.isExact();
		if (!report) return;

		// Make a special report for parameterized types if necessary
		 if (refBinding.isParameterizedType() && this.pattern.hasTypeArguments())  {
			TypeReference typeRef = null;
			TypeReference[] typeArguments = null;
			if (expr instanceof ParameterizedQualifiedTypeReference) {
				typeRef = (ParameterizedQualifiedTypeReference) expr;
				typeArguments = ((ParameterizedQualifiedTypeReference) expr).typeArguments[lastIndex];
			}
			else if (expr instanceof ParameterizedSingleTypeReference) {
				typeRef = (ParameterizedSingleTypeReference) expr;
				typeArguments = ((ParameterizedSingleTypeReference) expr).typeArguments;
			}
			if (typeRef != null) {
				locator.reportAccurateParameterizedTypeReference(this.match, typeRef, lastIndex, typeArguments);
				return;
			}
		}
	} else if (this.pattern.hasTypeArguments()) { // binding has no type params, compatible erasure if pattern does
		this.match.setRule(SearchPattern.R_ERASURE_MATCH);
	}

	// Report match
	if (expr instanceof ArrayTypeReference) {
		locator.reportAccurateTypeReference(this.match, expr, this.pattern.simpleName);
		return;
	}
	if (refBinding.isLocalType()) {
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=82673
		LocalTypeBinding local = (LocalTypeBinding) refBinding.erasure();
		IJavaElement focus = this.pattern.focus;
		if (focus != null && local.enclosingMethod != null && focus.getParent().getElementType() == IJavaElement.METHOD) {
			IMethod method = (IMethod) focus.getParent();
			if (!CharOperation.equals(local.enclosingMethod.selector, method.getElementName().toCharArray())) {
				return;
			}
		}
	}
	if (this.pattern.simpleName == null) {
		this.match.setOffset(expr.sourceStart);
		this.match.setLength(expr.sourceEnd-expr.sourceStart+1);
	}
	locator.report(this.match);
}
 
Example 19
Source File: SelectionOnReferenceExpressionName.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public boolean isMethodReference() {
	return !CharOperation.equals(this.selector, "new".toCharArray()); //$NON-NLS-1$
}
 
Example 20
Source File: JavaMethodCompletionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns whether we automatically complete the method with a semicolon.
 * 
 * @return <code>true</code> if the return type of the method is void, <code>false</code>
 *         otherwise
 * @since 3.9
 */
protected final boolean canAutomaticallyAppendSemicolon() {
	return !fProposal.isConstructor() && CharOperation.equals(new char[] { Signature.C_VOID }, Signature.getReturnType(fProposal.getSignature()));
}