Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#concatWith()
The following examples show how to use
org.eclipse.jdt.core.compiler.CharOperation#concatWith() .
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: FileSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public boolean isPackage(char[][] compoundName, char[] packageName) { String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/')); String qp2 = File.separatorChar == '/' ? qualifiedPackageName : qualifiedPackageName.replace('/', File.separatorChar); if (qualifiedPackageName == qp2) { for (int i = 0, length = this.classpaths.length; i < length; i++) if (this.classpaths[i].isPackage(qualifiedPackageName)) return true; } else { for (int i = 0, length = this.classpaths.length; i < length; i++) { Classpath p = this.classpaths[i]; if ((p instanceof ClasspathJar) ? p.isPackage(qualifiedPackageName) : p.isPackage(qp2)) return true; } } return false; }
Example 2
Source File: SourceElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected char[][] getTypeParameterBounds(TypeParameter typeParameter) { TypeReference firstBound = typeParameter.type; TypeReference[] otherBounds = typeParameter.bounds; char[][] typeParameterBounds = null; if (firstBound != null) { if (otherBounds != null) { int otherBoundsLength = otherBounds.length; char[][] boundNames = new char[otherBoundsLength+1][]; boundNames[0] = CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.'); for (int j = 0; j < otherBoundsLength; j++) { boundNames[j+1] = CharOperation.concatWith(otherBounds[j].getParameterizedTypeName(), '.'); } typeParameterBounds = boundNames; } else { typeParameterBounds = new char[][] { CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.')}; } } else { typeParameterBounds = CharOperation.NO_CHAR_CHAR; } return typeParameterBounds; }
Example 3
Source File: SourceElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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) { for (int i = 0; i < superInterfacesLength; i++) { interfaceNames[i] = CharOperation.concatWith(superInterfaces[i].getParameterizedTypeName(), '.'); } } return interfaceNames; }
Example 4
Source File: CompletionElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected char[][][] getArguments(Argument[] arguments) { int argumentLength = arguments.length; char[][] argumentTypes = new char[argumentLength][]; char[][] argumentNames = new char[argumentLength][]; int argumentCount = 0; next : for (int i = 0; i < argumentLength; i++) { Argument argument = arguments[i]; if (argument instanceof CompletionOnArgumentName && argument.name.length == 0) continue next; argumentTypes[argumentCount] = CharOperation.concatWith(argument.type.getParameterizedTypeName(), '.'); argumentNames[argumentCount++] = argument.name; } if (argumentCount < argumentLength) { System.arraycopy(argumentTypes, 0, argumentTypes = new char[argumentCount][], 0, argumentCount); System.arraycopy(argumentNames, 0, argumentNames = new char[argumentCount][], 0, argumentCount); } return new char[][][] {argumentTypes, argumentNames}; }
Example 5
Source File: ClassFileInfo.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IMemberValuePair[] getRetentionPolicy(long tagBits) { if ((tagBits & TagBits.AnnotationRetentionMASK) == 0) return Annotation.NO_MEMBER_VALUE_PAIRS; String retention = null; if ((tagBits & TagBits.AnnotationRuntimeRetention) == TagBits.AnnotationRuntimeRetention) { // TagBits.AnnotationRuntimeRetention combines both TagBits.AnnotationClassRetention & TagBits.AnnotationSourceRetention retention = new String(CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.' + new String(TypeConstants.UPPER_RUNTIME); } else if ((tagBits & TagBits.AnnotationSourceRetention) != 0) { retention = new String(CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.' + new String(TypeConstants.UPPER_SOURCE); } else { retention = new String(CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_RETENTIONPOLICY, '.')) + '.' + new String(TypeConstants.UPPER_CLASS); } final String value = retention; return new IMemberValuePair[] { new IMemberValuePair() { public int getValueKind() { return IMemberValuePair.K_QUALIFIED_NAME; } public Object getValue() { return value; } public String getMemberName() { return new String(TypeConstants.VALUE); } } }; }
Example 6
Source File: SourceElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected char[][] getThrownExceptions(AbstractMethodDeclaration methodDeclaration) { char[][] thrownExceptionTypes = null; TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions; if (thrownExceptions != null) { int thrownExceptionLength = thrownExceptions.length; thrownExceptionTypes = new char[thrownExceptionLength][]; for (int i = 0; i < thrownExceptionLength; i++) { thrownExceptionTypes[i] = CharOperation.concatWith(thrownExceptions[i].getParameterizedTypeName(), '.'); } } return thrownExceptionTypes; }
Example 7
Source File: ClassFileMatchLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
boolean matchTypeDeclaration(TypeDeclarationPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) { if (!(binaryInfo instanceof IBinaryType)) return false; IBinaryType type = (IBinaryType) binaryInfo; char[] fullyQualifiedTypeName = convertClassFileFormat(type.getName()); boolean qualifiedPattern = pattern instanceof QualifiedTypeDeclarationPattern; if (pattern.enclosingTypeNames == null || qualifiedPattern) { char[] simpleName = (pattern.getMatchMode() == SearchPattern.R_PREFIX_MATCH) ? CharOperation.concat(pattern.simpleName, IIndexConstants.ONE_STAR) : pattern.simpleName; char[] pkg = qualifiedPattern ? ((QualifiedTypeDeclarationPattern)pattern).qualification : pattern.pkg; if (!checkTypeName(simpleName, pkg, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; } else { char[] enclosingTypeName = CharOperation.concatWith(pattern.enclosingTypeNames, '.'); char[] patternString = pattern.pkg == null ? enclosingTypeName : CharOperation.concat(pattern.pkg, enclosingTypeName, '.'); if (!checkTypeName(pattern.simpleName, patternString, fullyQualifiedTypeName, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; } int kind = TypeDeclaration.kind(type.getModifiers()); switch (pattern.typeSuffix) { case CLASS_SUFFIX: return kind == TypeDeclaration.CLASS_DECL; case INTERFACE_SUFFIX: return kind == TypeDeclaration.INTERFACE_DECL; case ENUM_SUFFIX: return kind == TypeDeclaration.ENUM_DECL; case ANNOTATION_TYPE_SUFFIX: return kind == TypeDeclaration.ANNOTATION_TYPE_DECL; case CLASS_AND_INTERFACE_SUFFIX: return kind == TypeDeclaration.CLASS_DECL || kind == TypeDeclaration.INTERFACE_DECL; case CLASS_AND_ENUM_SUFFIX: return kind == TypeDeclaration.CLASS_DECL || kind == TypeDeclaration.ENUM_DECL; case INTERFACE_AND_ANNOTATION_SUFFIX: return kind == TypeDeclaration.INTERFACE_DECL || kind == TypeDeclaration.ANNOTATION_TYPE_DECL; case TYPE_SUFFIX: // nothing } return true; }
Example 8
Source File: CompletionElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected char[][] getTypeParameterBounds(TypeParameter typeParameter) { TypeReference firstBound = typeParameter.type; TypeReference[] otherBounds = typeParameter.bounds; char[][] typeParameterBounds = null; if (firstBound != null) { if (otherBounds != null) { int otherBoundsLength = otherBounds.length; char[][] boundNames = new char[otherBoundsLength+1][]; int boundCount = 0; if (!CompletionUnitStructureRequestor.hasEmptyName(firstBound, this.assistNode)) { boundNames[boundCount++] = CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.'); } for (int j = 0; j < otherBoundsLength; j++) { TypeReference otherBound = otherBounds[j]; if (!CompletionUnitStructureRequestor.hasEmptyName(otherBound, this.assistNode)) { boundNames[boundCount++] = CharOperation.concatWith(otherBound.getParameterizedTypeName(), '.'); } } if (boundCount == 0) { boundNames = CharOperation.NO_CHAR_CHAR; } else if (boundCount < otherBoundsLength + 1){ System.arraycopy(boundNames, 0, boundNames = new char[boundCount][], 0, boundCount); } typeParameterBounds = boundNames; } else { if (!CompletionUnitStructureRequestor.hasEmptyName(firstBound, this.assistNode)) { typeParameterBounds = new char[][] { CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.')}; } else { typeParameterBounds = CharOperation.NO_CHAR_CHAR; } } } else { typeParameterBounds = CharOperation.NO_CHAR_CHAR; } return typeParameterBounds; }
Example 9
Source File: CompletionElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 10
Source File: CompletionElementNotifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 11
Source File: SourceMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see ISourceElementRequestor */ public void acceptImport( int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { char[][] imports = (char[][]) this.importsTable.get(this.binaryType); int importsCounter; if (imports == null) { imports = new char[5][]; importsCounter = 0; } else { importsCounter = ((Integer) this.importsCounterTable.get(this.binaryType)).intValue(); } if (imports.length == importsCounter) { System.arraycopy( imports, 0, (imports = new char[importsCounter * 2][]), 0, importsCounter); } char[] name = CharOperation.concatWith(tokens, '.'); if (onDemand) { int nameLength = name.length; System.arraycopy(name, 0, (name = new char[nameLength + 2]), 0, nameLength); name[nameLength] = '.'; name[nameLength + 1] = '*'; } imports[importsCounter++] = name; this.importsTable.put(this.binaryType, imports); this.importsCounterTable.put(this.binaryType, new Integer(importsCounter)); }
Example 12
Source File: ErrorTypeElement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Name getQualifiedName() { ReferenceBinding binding = (ReferenceBinding)_binding; char[] qName; if (binding.isMemberType()) { qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.'); CharOperation.replace(qName, '$', '.'); } else { qName = CharOperation.concatWith(binding.compoundName, '.'); } return new NameImpl(qName); }
Example 13
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 14
Source File: TypeElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Name getQualifiedName() { ReferenceBinding binding = (ReferenceBinding)_binding; char[] qName; if (binding.isMemberType()) { qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.'); CharOperation.replace(qName, '$', '.'); } else { qName = CharOperation.concatWith(binding.compoundName, '.'); } return new NameImpl(qName); }
Example 15
Source File: PackageBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public char[] computeUniqueKey(boolean isLeaf) { return CharOperation.concatWith(this.compoundName, '/'); }
Example 16
Source File: LocalVariable.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private Object getAnnotationMemberValue(MemberValuePair memberValuePair, Expression expression, JavaElement parentElement) { if (expression instanceof NullLiteral) { return null; } else if (expression instanceof Literal) { ((Literal) expression).computeConstant(); return Util.getAnnotationMemberValue(memberValuePair, expression.constant); } else if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) { memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION; return getAnnotation((org.eclipse.jdt.internal.compiler.ast.Annotation) expression, parentElement); } else if (expression instanceof ClassLiteralAccess) { ClassLiteralAccess classLiteral = (ClassLiteralAccess) expression; char[] typeName = CharOperation.concatWith(classLiteral.type.getTypeName(), '.'); memberValuePair.valueKind = IMemberValuePair.K_CLASS; return new String(typeName); } else if (expression instanceof QualifiedNameReference) { char[] qualifiedName = CharOperation.concatWith(((QualifiedNameReference) expression).tokens, '.'); memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME; return new String(qualifiedName); } else if (expression instanceof SingleNameReference) { char[] simpleName = ((SingleNameReference) expression).token; if (simpleName == RecoveryScanner.FAKE_IDENTIFIER) { memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; } memberValuePair.valueKind = IMemberValuePair.K_SIMPLE_NAME; return new String(simpleName); } else if (expression instanceof ArrayInitializer) { memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...) Expression[] expressions = ((ArrayInitializer) expression).expressions; int length = expressions == null ? 0 : expressions.length; Object[] values = new Object[length]; for (int i = 0; i < length; i++) { int previousValueKind = memberValuePair.valueKind; Object value = getAnnotationMemberValue(memberValuePair, expressions[i], parentElement); if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) { // values are heterogeneous, value kind is thus unknown memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; } values[i] = value; } if (memberValuePair.valueKind == -1) memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return values; } else if (expression instanceof UnaryExpression) { //to deal with negative numerals (see bug - 248312) UnaryExpression unaryExpression = (UnaryExpression) expression; if ((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == OperatorIds.MINUS) { if (unaryExpression.expression instanceof Literal) { Literal subExpression = (Literal) unaryExpression.expression; subExpression.computeConstant(); return Util.getNegativeAnnotationMemberValue(memberValuePair, subExpression.constant); } } memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; } else { memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; } }
Example 17
Source File: PackageBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public char[] readableName() /*java.lang*/ { return CharOperation.concatWith(this.compoundName, '.'); }
Example 18
Source File: Classpath.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
@Override public boolean isPackage(char[][] parentPackageName, char[] packageName) { String name = new String(CharOperation.concatWith(parentPackageName, packageName, '/')); return packages.containsKey(name); }
Example 19
Source File: ClassFileInfo.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private IMemberValuePair[] getTargetElementTypes(long tagBits) { ArrayList values = new ArrayList(); String elementType = new String(CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE, '.')) + '.'; if ((tagBits & TagBits.AnnotationForType) != 0) { values.add(elementType + new String(TypeConstants.TYPE)); } if ((tagBits & TagBits.AnnotationForField) != 0) { values.add(elementType + new String(TypeConstants.UPPER_FIELD)); } if ((tagBits & TagBits.AnnotationForMethod) != 0) { values.add(elementType + new String(TypeConstants.UPPER_METHOD)); } if ((tagBits & TagBits.AnnotationForParameter) != 0) { values.add(elementType + new String(TypeConstants.UPPER_PARAMETER)); } if ((tagBits & TagBits.AnnotationForConstructor) != 0) { values.add(elementType + new String(TypeConstants.UPPER_CONSTRUCTOR)); } if ((tagBits & TagBits.AnnotationForLocalVariable) != 0) { values.add(elementType + new String(TypeConstants.UPPER_LOCAL_VARIABLE)); } if ((tagBits & TagBits.AnnotationForAnnotationType) != 0) { values.add(elementType + new String(TypeConstants.UPPER_ANNOTATION_TYPE)); } if ((tagBits & TagBits.AnnotationForPackage) != 0) { values.add(elementType + new String(TypeConstants.UPPER_PACKAGE)); } final Object value; if (values.size() == 0) { if ((tagBits & TagBits.AnnotationTarget) != 0) value = CharOperation.NO_STRINGS; else return Annotation.NO_MEMBER_VALUE_PAIRS; } else if (values.size() == 1) { value = values.get(0); } else { value = values.toArray(new String[values.size()]); } return new IMemberValuePair[] { new IMemberValuePair() { public int getValueKind() { return IMemberValuePair.K_QUALIFIED_NAME; } public Object getValue() { return value; } public String getMemberName() { return new String(TypeConstants.VALUE); } } }; }
Example 20
Source File: ReferenceBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Answer the receiver's constant pool name. * * NOTE: This method should only be used during/after code gen. */ public char[] constantPoolName() /* java/lang/Object */ { if (this.constantPoolName != null) return this.constantPoolName; return this.constantPoolName = CharOperation.concatWith(this.compoundName, '/'); }