Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#concat()
The following examples show how to use
org.eclipse.jdt.core.compiler.CharOperation#concat() .
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: WildcardBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public char[] computeUniqueKey(boolean isLeaf) { char[] genericTypeKey = this.genericType.computeUniqueKey(false/*not a leaf*/); char[] wildCardKey; // We now encode the rank also in the binding key - https://bugs.eclipse.org/bugs/show_bug.cgi?id=234609 char[] rankComponent = ('{' + String.valueOf(this.rank) + '}').toCharArray(); switch (this.boundKind) { case Wildcard.UNBOUND : wildCardKey = TypeConstants.WILDCARD_STAR; break; case Wildcard.EXTENDS : wildCardKey = CharOperation.concat(TypeConstants.WILDCARD_PLUS, this.bound.computeUniqueKey(false/*not a leaf*/)); break; default: // SUPER wildCardKey = CharOperation.concat(TypeConstants.WILDCARD_MINUS, this.bound.computeUniqueKey(false/*not a leaf*/)); break; } return CharOperation.concat(genericTypeKey, rankComponent, wildCardKey); }
Example 2
Source File: InferenceVariable.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public InferenceVariable(TypeBinding typeParameter, int variableRank, InvocationSite site, LookupEnvironment environment, ReferenceBinding object) { super(CharOperation.concat(typeParameter.shortReadableName(), Integer.toString(variableRank).toCharArray(), '#'), null/*declaringElement*/, variableRank, environment); this.site = site; this.typeParameter = typeParameter; this.tagBits |= typeParameter.tagBits & TagBits.AnnotationNullMASK; if (typeParameter.isTypeVariable()) { TypeVariableBinding typeVariable = (TypeVariableBinding) typeParameter; if (typeVariable.firstBound != null) { long boundBits = typeVariable.firstBound.tagBits & TagBits.AnnotationNullMASK; if (boundBits == TagBits.AnnotationNonNull) this.tagBits |= boundBits; // @NonNull must be preserved else this.nullHints |= boundBits; // @Nullable is only a hint } } this.superclass = object; }
Example 3
Source File: MethodInfo.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void decodeMethodParameters(int offset, MethodInfo methodInfo) { int readOffset = offset + 6; final int length = u1At(readOffset); if (length != 0) { readOffset += 1; this.argumentNames = new char[length][]; for (int i = 0; i < length; i++) { int nameIndex = u2At(readOffset); if (nameIndex != 0) { int utf8Offset = this.constantPoolOffsets[nameIndex] - this.structOffset; char[] parameterName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); this.argumentNames[i] = parameterName; } else { this.argumentNames[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray()); } readOffset += 4; } } }
Example 4
Source File: Wildcard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char [][] getParameterizedTypeName() { switch (this.kind) { case Wildcard.UNBOUND : return new char[][] { WILDCARD_NAME }; case Wildcard.EXTENDS : return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_EXTENDS, CharOperation.concatWith(this.bound.getParameterizedTypeName(), '.')) }; default: // SUPER return new char[][] { CharOperation.concat(WILDCARD_NAME, WILDCARD_SUPER, CharOperation.concatWith(this.bound.getParameterizedTypeName(), '.')) }; } }
Example 5
Source File: DOMMember.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns a <code>String</code> describing the modifiers for this member, * ending with whitespace (if not empty). This value serves as a replacement * value for the member's modifier range when the modifiers have been altered * from their original contents. */ protected char[] generateFlags() { char[] flags= Flags.toString(getFlags()).toCharArray(); if (flags.length == 0) { return flags; } else { return CharOperation.concat(flags, new char[] {' '}); } }
Example 6
Source File: SyntheticArgumentBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public SyntheticArgumentBinding(LocalVariableBinding actualOuterLocalVariable) { super( CharOperation.concat(TypeConstants.SYNTHETIC_OUTER_LOCAL_PREFIX, actualOuterLocalVariable.name), actualOuterLocalVariable.type, ClassFileConstants.AccFinal, true); this.actualOuterLocalVariable = actualOuterLocalVariable; }
Example 7
Source File: Disassembler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private char[][] getParameterNames(char[] methodDescriptor, ICodeAttribute codeAttribute, IMethodParametersAttribute parametersAttribute, int accessFlags) { int paramCount = Signature.getParameterCount(methodDescriptor); char[][] parameterNames = new char[paramCount][]; // check if the code attribute has debug info for this method if (parametersAttribute != null) { int parameterCount = parametersAttribute.getMethodParameterLength(); for (int i = 0; i < paramCount; i++) { if (i < parameterCount && parametersAttribute.getParameterName(i) != null) { parameterNames[i] = parametersAttribute.getParameterName(i); } else { parameterNames[i] = Messages.disassembler_anonymousparametername.toCharArray(); } } } else if (codeAttribute != null) { ILocalVariableAttribute localVariableAttribute = codeAttribute.getLocalVariableAttribute(); if (localVariableAttribute != null) { ILocalVariableTableEntry[] entries = localVariableAttribute.getLocalVariableTable(); final int startingIndex = (accessFlags & IModifierConstants.ACC_STATIC) != 0 ? 0 : 1; for (int i = 0; i < paramCount; i++) { ILocalVariableTableEntry searchedEntry = getEntryFor(getLocalIndex(startingIndex, i, methodDescriptor), entries); if (searchedEntry != null) { parameterNames[i] = searchedEntry.getName(); } else { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } } else { for (int i = 0; i < paramCount; i++) { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } } else { for (int i = 0; i < paramCount; i++) { parameterNames[i] = CharOperation.concat(Messages.disassembler_parametername.toCharArray(), Integer.toString(i).toCharArray()); } } return parameterNames; }
Example 8
Source File: ParameterizedQualifiedTypeReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @return char[][] */ public char [][] getParameterizedTypeName(){ int length = this.tokens.length; char[][] qParamName = new char[length][]; for (int i = 0; i < length; i++) { TypeReference[] arguments = this.typeArguments[i]; if (arguments == null) { qParamName[i] = this.tokens[i]; } else { StringBuffer buffer = new StringBuffer(5); buffer.append(this.tokens[i]); buffer.append('<'); for (int j = 0, argLength =arguments.length; j < argLength; j++) { if (j > 0) buffer.append(','); buffer.append(CharOperation.concatWith(arguments[j].getParameterizedTypeName(), '.')); } buffer.append('>'); int nameLength = buffer.length(); qParamName[i] = new char[nameLength]; buffer.getChars(0, nameLength, qParamName[i], 0); } } int dim = this.dimensions; if (dim > 0) { char[] dimChars = new char[dim*2]; for (int i = 0; i < dim; i++) { int index = i*2; dimChars[index] = '['; dimChars[index+1] = ']'; } qParamName[length-1] = CharOperation.concat(qParamName[length-1], dimChars); } return qParamName; }
Example 9
Source File: WildcardBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char[] sourceName() { switch (this.boundKind) { case Wildcard.UNBOUND : return TypeConstants.WILDCARD_NAME; case Wildcard.EXTENDS : return CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_EXTENDS, this.bound.sourceName()); default: // SUPER return CharOperation.concat(TypeConstants.WILDCARD_NAME, TypeConstants.WILDCARD_SUPER, this.bound.sourceName()); } }
Example 10
Source File: MethodPattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public EntryResult[] queryIn(Index index) throws IOException { char[] key = this.selector; // can be null int matchRule = getMatchRule(); switch(getMatchMode()) { case R_EXACT_MATCH : if (this.selector != null && this.parameterCount >= 0 && !this.varargs) key = createIndexKey(this.selector, this.parameterCount); else { // do a prefix query with the selector matchRule &= ~R_EXACT_MATCH; matchRule |= R_PREFIX_MATCH; } break; case R_PREFIX_MATCH : // do a prefix query with the selector break; case R_PATTERN_MATCH : if (this.parameterCount >= 0 && !this.varargs) key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount); else if (this.selector != null && this.selector[this.selector.length - 1] != '*') key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR); // else do a pattern query with just the selector break; case R_REGEXP_MATCH : // TODO (frederic) implement regular expression match break; case R_CAMELCASE_MATCH: case R_CAMELCASE_SAME_PART_COUNT_MATCH: // do a prefix query with the selector break; } return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null }
Example 11
Source File: ArrayBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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 12
Source File: ArrayBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char[] nullAnnotatedReadableName(CompilerOptions options, boolean shortNames) /* java.lang.Object @o.e.j.a.NonNull[] */ { if (this.nullTagBitsPerDimension == null) return shortNames ? shortReadableName() : readableName(); char[][] brackets = new char[this.dimensions][]; for (int i = 0; i < this.dimensions; i++) { if ((this.nullTagBitsPerDimension[i] & TagBits.AnnotationNullMASK) != 0) { char[][] fqAnnotationName; if ((this.nullTagBitsPerDimension[i] & TagBits.AnnotationNonNull) != 0) fqAnnotationName = options.nonNullAnnotationName; else fqAnnotationName = options.nullableAnnotationName; char[] annotationName = shortNames ? fqAnnotationName[fqAnnotationName.length-1] : CharOperation.concatWith(fqAnnotationName, '.'); brackets[i] = new char[annotationName.length+3]; brackets[i][0] = '@'; System.arraycopy(annotationName, 0, brackets[i], 1, annotationName.length); brackets[i][annotationName.length+1] = '['; brackets[i][annotationName.length+2] = ']'; } else { brackets[i] = new char[]{'[', ']'}; } } return CharOperation.concat(this.leafComponentType.nullAnnotatedReadableName(options, shortNames), CharOperation.concatWith(brackets, ' '), ' '); }
Example 13
Source File: ReferenceBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Answer the source name for the type. * In the case of member types, as the qualified name from its top level type. * For example, for a member type N defined inside M & A: "A.M.N". */ public char[] qualifiedSourceName() { if (isMemberType()) return CharOperation.concat(enclosingType().qualifiedSourceName(), sourceName(), '.'); return sourceName(); }
Example 14
Source File: SyntheticMethodBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * An method accessor is a method with an access$N selector, where N is incremented in case of collisions. */ public void initializeMethodAccessor(MethodBinding accessedMethod, boolean isSuperAccess, ReferenceBinding receiverType) { this.targetMethod = accessedMethod; if (isSuperAccess && receiverType.isInterface() && !accessedMethod.isStatic()) this.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccSynthetic; else this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic; this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved); SourceTypeBinding declaringSourceType = (SourceTypeBinding) receiverType; SyntheticMethodBinding[] knownAccessMethods = declaringSourceType.syntheticMethods(); int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length; this.index = methodId; this.selector = CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(methodId).toCharArray()); this.returnType = accessedMethod.returnType; this.purpose = isSuperAccess ? SyntheticMethodBinding.SuperMethodAccess : SyntheticMethodBinding.MethodAccess; if (accessedMethod.isStatic() || (isSuperAccess && receiverType.isInterface())) { this.parameters = accessedMethod.parameters; } else { this.parameters = new TypeBinding[accessedMethod.parameters.length + 1]; this.parameters[0] = declaringSourceType; System.arraycopy(accessedMethod.parameters, 0, this.parameters, 1, accessedMethod.parameters.length); } this.thrownExceptions = accessedMethod.thrownExceptions; this.declaringClass = declaringSourceType; // check for method collision boolean needRename; do { check : { needRename = false; // check for collision with known methods MethodBinding[] methods = declaringSourceType.methods(); for (int i = 0, length = methods.length; i < length; i++) { if (CharOperation.equals(this.selector, methods[i].selector) && areParameterErasuresEqual(methods[i])) { needRename = true; break check; } } // check for collision with synthetic accessors if (knownAccessMethods != null) { for (int i = 0, length = knownAccessMethods.length; i < length; i++) { if (knownAccessMethods[i] == null) continue; if (CharOperation.equals(this.selector, knownAccessMethods[i].selector) && areParameterErasuresEqual(knownAccessMethods[i])) { needRename = true; break check; } } } } if (needRename) { // retry with a selector & a growing methodId setSelector(CharOperation.concat(TypeConstants.SYNTHETIC_ACCESS_METHOD_PREFIX, String.valueOf(++methodId).toCharArray())); } } while (needRename); // retrieve sourceStart position for the target method for line number attributes AbstractMethodDeclaration[] methodDecls = declaringSourceType.scope.referenceContext.methods; if (methodDecls != null) { for (int i = 0, length = methodDecls.length; i < length; i++) { if (methodDecls[i].binding == accessedMethod) { this.sourceStart = methodDecls[i].sourceStart; return; } } } }
Example 15
Source File: SourceTypeBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public SyntheticFieldBinding addSyntheticFieldForSwitchEnum(char[] fieldName, String key) { if (!isPrototype()) throw new IllegalStateException(); if (this.synthetics == null) this.synthetics = new HashMap[MAX_SYNTHETICS]; if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null) this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5); SyntheticFieldBinding synthField = (SyntheticFieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL].get(key); if (synthField == null) { synthField = new SyntheticFieldBinding( fieldName, this.scope.createArrayType(TypeBinding.INT,1), (isInterface() ? (ClassFileConstants.AccPublic | ClassFileConstants.AccFinal) : ClassFileConstants.AccPrivate) | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic, this, Constant.NotAConstant, this.synthetics[SourceTypeBinding.FIELD_EMUL].size()); this.synthetics[SourceTypeBinding.FIELD_EMUL].put(key, synthField); } // ensure there is not already such a field defined by the user boolean needRecheck; int index = 0; do { needRecheck = false; FieldBinding existingField; if ((existingField = getField(synthField.name, true /*resolve*/)) != null) { TypeDeclaration typeDecl = this.scope.referenceContext; FieldDeclaration[] fieldDeclarations = typeDecl.fields; int max = fieldDeclarations == null ? 0 : fieldDeclarations.length; for (int i = 0; i < max; i++) { FieldDeclaration fieldDecl = fieldDeclarations[i]; if (fieldDecl.binding == existingField) { synthField.name = CharOperation.concat( fieldName, ("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$ needRecheck = true; break; } } } } while (needRecheck); return synthField; }
Example 16
Source File: BinaryType.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void codeComplete( char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { if (requestor == null) { throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$ } JavaProject project = (JavaProject) getJavaProject(); SearchableEnvironment environment = project.newSearchableNameEnvironment(owner); CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor); String source = getClassFile().getSource(); if (source != null && insertion > -1 && insertion < source.length()) { // code complete char[] prefix = CharOperation.concat(source.substring(0, insertion).toCharArray(), new char[]{'{'}); char[] suffix = CharOperation.concat(new char[]{'}'}, source.substring(insertion).toCharArray()); char[] fakeSource = CharOperation.concat(prefix, snippet, suffix); BasicCompilationUnit cu = new BasicCompilationUnit( fakeSource, null, getElementName(), project); // use project to retrieve corresponding .java IFile engine.complete(cu, prefix.length + position, prefix.length, null/*extended context isn't computed*/); } else { engine.complete(this, snippet, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic); } if (NameLookup.VERBOSE) { System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } }
Example 17
Source File: CompletionOnArgumentName.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public CompletionOnArgumentName(char[] name , long posNom , TypeReference tr , int modifiers){ super(CharOperation.concat(name, FAKENAMESUFFIX), posNom, tr, modifiers); this.realName = name; }
Example 18
Source File: CompletionOnFieldName.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public CompletionOnFieldName(char[] name, int sourceStart, int sourceEnd) { super(CharOperation.concat(name, FAKENAMESUFFIX), sourceStart, sourceEnd); this.realName = name; }
Example 19
Source File: TypeVariableBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * T::Ljava/util/Map;:Ljava/io/Serializable; * T:LY<TT;> */ public char[] genericTypeSignature() { if (this.genericTypeSignature != null) return this.genericTypeSignature; return this.genericTypeSignature = CharOperation.concat('T', this.sourceName, ';'); }
Example 20
Source File: CompletionOnLocalName.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public CompletionOnLocalName(char[] name, int sourceStart, int sourceEnd){ super(CharOperation.concat(name, FAKENAMESUFFIX), sourceStart, sourceEnd); this.realName = name; }