Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#NO_CHAR_CHAR
The following examples show how to use
org.eclipse.jdt.core.compiler.CharOperation#NO_CHAR_CHAR .
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: Signature.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Extracts the type bounds' signatures from the given intersection type signature. * Returns an empty array if the type signature is not an intersection type signature. * * @param intersectionTypeSignature the intersection type signature * @return the signatures of the type bounds * @exception IllegalArgumentException if the signature is syntactically incorrect * * @since 3.7.1 */ public static char[][] getIntersectionTypeBounds(char[] intersectionTypeSignature) throws IllegalArgumentException { if (getTypeSignatureKind(intersectionTypeSignature) != INTERSECTION_TYPE_SIGNATURE) { return CharOperation.NO_CHAR_CHAR; } ArrayList args = new ArrayList(); int i = 1; // skip the '|' int length = intersectionTypeSignature.length; for (;;) { int e = Util.scanClassTypeSignature(intersectionTypeSignature, i); if (e < 0) { throw new IllegalArgumentException("Invalid format"); //$NON-NLS-1$ } args.add(CharOperation.subarray(intersectionTypeSignature, i, e + 1)); if (e == length - 1) { int size = args.size(); char[][] result = new char[size][]; args.toArray(result); return result; } else if (intersectionTypeSignature[e + 1] != C_COLON) { throw new IllegalArgumentException("Invalid format"); //$NON-NLS-1$ } i = e + 2; // add one to skip C_COLON } }
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: ExceptionAttribute.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
ExceptionAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); this.exceptionsNumber = u2At(classFileBytes, 6, offset); int exceptionLength = this.exceptionsNumber; this.exceptionNames = CharOperation.NO_CHAR_CHAR; this.exceptionIndexes = org.eclipse.jdt.internal.compiler.util.Util.EMPTY_INT_ARRAY; if (exceptionLength != 0) { this.exceptionNames = new char[exceptionLength][]; this.exceptionIndexes = new int[exceptionLength]; } int readOffset = 8; IConstantPoolEntry constantPoolEntry; for (int i = 0; i < exceptionLength; i++) { this.exceptionIndexes[i] = u2At(classFileBytes, readOffset, offset); constantPoolEntry = constantPool.decodeEntry(this.exceptionIndexes[i]); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } this.exceptionNames[i] = constantPoolEntry.getClassInfoName(); readOffset += 2; } }
Example 4
Source File: CompilationUnitScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public CompilationUnitScope(CompilationUnitDeclaration unit, LookupEnvironment environment) { super(COMPILATION_UNIT_SCOPE, null); this.environment = environment; this.referenceContext = unit; unit.scope = this; this.currentPackageName = unit.currentPackage == null ? CharOperation.NO_CHAR_CHAR : unit.currentPackage.tokens; if (compilerOptions().produceReferenceInfo) { this.qualifiedReferences = new CompoundNameVector(); this.simpleNameReferences = new SimpleNameVector(); this.rootReferences = new SimpleNameVector(); this.referencedTypes = new ObjectVector(); this.referencedSuperTypes = new ObjectVector(); } else { this.qualifiedReferences = null; // used to test if dependencies should be recorded this.simpleNameReferences = null; this.rootReferences = null; this.referencedTypes = null; this.referencedSuperTypes = null; } }
Example 5
Source File: SourceTypeElementInfo.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char[][] getTypeParameterNames() { int length = this.typeParameters.length; if (length == 0) return CharOperation.NO_CHAR_CHAR; char[][] typeParameterNames = new char[length][]; for (int i = 0; i < length; i++) { typeParameterNames[i] = this.typeParameters[i].getElementName().toCharArray(); } return typeParameterNames; }
Example 6
Source File: SourceJavadocParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean checkDeprecation(int commentPtr) { this.categoriesPtr = -1; boolean result = super.checkDeprecation(commentPtr); if (this.categoriesPtr > -1) { System.arraycopy(this.categories, 0, this.categories = new char[this.categoriesPtr+1][], 0, this.categoriesPtr+1); } else { this.categories = CharOperation.NO_CHAR_CHAR; } return result; }
Example 7
Source File: Signature.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Extracts the class and interface bounds from the given formal type * parameter signature. The class bound, if present, is listed before * the interface bounds. The signature is expected to be dot-based. * * @param formalTypeParameterSignature the formal type parameter signature * @return the (possibly empty) list of type signatures for the bounds * @exception IllegalArgumentException if the signature is syntactically * incorrect * @since 3.0 */ public static char[][] getTypeParameterBounds(char[] formalTypeParameterSignature) throws IllegalArgumentException { int p1 = CharOperation.indexOf(C_COLON, formalTypeParameterSignature); if (p1 < 0) { // no ":" means can't be a formal type parameter signature throw new IllegalArgumentException(); } if (p1 == formalTypeParameterSignature.length - 1) { // no class or interface bounds return CharOperation.NO_CHAR_CHAR; } int p2 = CharOperation.indexOf(C_COLON, formalTypeParameterSignature, p1 + 1); char[] classBound; if (p2 < 0) { // no interface bounds classBound = CharOperation.subarray(formalTypeParameterSignature, p1 + 1, formalTypeParameterSignature.length); return new char[][] {classBound}; } if (p2 == p1 + 1) { // no class bound, but 1 or more interface bounds classBound = null; } else { classBound = CharOperation.subarray(formalTypeParameterSignature, p1 + 1, p2); } char[][] interfaceBounds = CharOperation.splitOn(C_COLON, formalTypeParameterSignature, p2 + 1, formalTypeParameterSignature.length); if (classBound == null) { return interfaceBounds; } int resultLength = interfaceBounds.length + 1; char[][] result = new char[resultLength][]; result[0] = classBound; System.arraycopy(interfaceBounds, 0, result, 1, interfaceBounds.length); return result; }
Example 8
Source File: Util.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Converts a String[] to char[][]. */ public static char[][] toCharArrays(String[] a) { int len = a.length; if (len == 0) return CharOperation.NO_CHAR_CHAR; char[][] result = new char[len][]; for (int i = 0; i < len; ++i) { result[i] = a[i].toCharArray(); } return result; }
Example 9
Source File: SourceMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Sets the mapping for this method to its parameter names. * * @see #parameterNames */ protected void setMethodParameterNames( IMethod method, char[][] parameterNames) { if (parameterNames == null) { parameterNames = CharOperation.NO_CHAR_CHAR; } this.parameterNames.put(method, parameterNames); }
Example 10
Source File: SourceMethodElementInfo.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char[][] getTypeParameterNames() { int length = this.typeParameters.length; if (length == 0) return CharOperation.NO_CHAR_CHAR; char[][] typeParameterNames = new char[length][]; for (int i = 0; i < length; i++) { typeParameterNames[i] = this.typeParameters[i].getElementName().toCharArray(); } return typeParameterNames; }
Example 11
Source File: PackageBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String toString() { String str; if (this.compoundName == CharOperation.NO_CHAR_CHAR) { str = "The Default Package"; //$NON-NLS-1$ } else { str = "package " + ((this.compoundName != null) ? CharOperation.toString(this.compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$ } if ((this.tagBits & TagBits.HasMissingType) != 0) { str += "[MISSING]"; //$NON-NLS-1$ } return str; }
Example 12
Source File: Signature.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns all segments of the given dot-separated qualified name. * Returns an array with only the given name if it is not qualified. * Returns an empty array if the name is empty. * <p> * For example: * <pre> * <code> * getSimpleNames({'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'}) -> {{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'O', 'b', 'j', 'e', 'c', 't'}} * getSimpleNames({'O', 'b', 'j', 'e', 'c', 't'}) -> {{'O', 'b', 'j', 'e', 'c', 't'}} * getSimpleNames({}) -> {} * getSimpleNames({'j', 'a', 'v', 'a', '.', 'u', 't', 'i', 'l', '.', 'L', 'i', 's', 't', '<', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '>'}) -> {{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'L', 'i', 's', 't', '<', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g'}} * </code> * </pre> * * @param name the name * @return the list of simple names, possibly empty * @exception NullPointerException if name is null * @since 2.0 */ public static char[][] getSimpleNames(char[] name) { int length = name == null ? 0 : name.length; if (length == 0) return CharOperation.NO_CHAR_CHAR; int wordCount = 1; countingWords: for (int i = 0; i < length; i++) switch(name[i]) { case C_DOT: wordCount++; break; case C_GENERIC_START: break countingWords; } char[][] split = new char[wordCount][]; int last = 0, currentWord = 0; for (int i = 0; i < length; i++) { if (name[i] == C_GENERIC_START) break; if (name[i] == C_DOT) { split[currentWord] = new char[i - last]; System.arraycopy( name, last, split[currentWord++], 0, i - last); last = i + 1; } } split[currentWord] = new char[length - last]; System.arraycopy(name, last, split[currentWord], 0, length - last); return split; }
Example 13
Source File: TypeBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
Example 14
Source File: MethodPattern.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public char[][] getIndexCategories() { if (this.findReferences) return this.findDeclarations ? REF_AND_DECL_CATEGORIES : REF_CATEGORIES; if (this.findDeclarations) return DECL_CATEGORIES; return CharOperation.NO_CHAR_CHAR; }
Example 15
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 16
Source File: ProjectAwareUniqueClassNameValidator.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public boolean doCheckUniqueInProject(QualifiedName name, JvmDeclaredType type) throws JavaModelException { IJavaProject javaProject = javaProjectProvider.getJavaProject(type.eResource().getResourceSet()); getContext().put(ProjectAwareUniqueClassNameValidator.OUTPUT_CONFIGS, outputConfigurationProvider.getOutputConfigurations(type.eResource())); String packageName = type.getPackageName(); String typeName = type.getSimpleName(); IndexManager indexManager = JavaModelManager.getIndexManager(); List<IPackageFragmentRoot> sourceFolders = new ArrayList<>(); for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceFolders.add(root); } } if (sourceFolders.isEmpty() || indexManager.awaitingJobsCount() > 0) { // still indexing - don't enter a busy wait loop but ask the source folders directly SourceTraversal sourceTraversal = doCheckUniqueInProjectSource(packageName != null ? packageName : "", typeName, type, sourceFolders); if (sourceTraversal == SourceTraversal.DUPLICATE) { return false; } else if (sourceTraversal == SourceTraversal.UNIQUE) { return true; } } Set<String> workingCopyPaths = new HashSet<>(); ICompilationUnit[] copies = getWorkingCopies(type); if (copies != null) { for (ICompilationUnit workingCopy : copies) { IPath path = workingCopy.getPath(); if (javaProject.getPath().isPrefixOf(path) && !isDerived(workingCopy.getResource())) { if (workingCopy.getPackageDeclaration(packageName).exists()) { IType result = workingCopy.getType(typeName); if (result.exists()) { addIssue(type, workingCopy.getElementName()); return false; } } workingCopyPaths.add(workingCopy.getPath().toString()); } } } // The code below is adapted from BasicSearchEnginge.searchAllSecondaryTypes // The Index is ready, query it for a secondary type char[] pkg = packageName == null ? CharOperation.NO_CHAR : packageName.toCharArray(); TypeDeclarationPattern pattern = new TypeDeclarationPattern(pkg, // CharOperation.NO_CHAR_CHAR, // top level type - no enclosing type names typeName.toCharArray(), // IIndexConstants.TYPE_SUFFIX, // SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); IndexQueryRequestor searchRequestor = new IndexQueryRequestor() { @Override public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) { if (workingCopyPaths.contains(documentPath)) { return true; // filter out working copies } IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(documentPath)); if (!isDerived(file)) { addIssue(type, file.getName()); return false; } return true; } }; try { SearchParticipant searchParticipant = BasicSearchEngine.getDefaultSearchParticipant(); // Java search only IJavaSearchScope javaSearchScope = BasicSearchEngine.createJavaSearchScope(sourceFolders.toArray(new IJavaElement[0])); PatternSearchJob patternSearchJob = new PatternSearchJob(pattern, searchParticipant, javaSearchScope, searchRequestor); indexManager.performConcurrentJob(patternSearchJob, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); return true; } catch (Throwable OperationCanceledException) { return false; } }
Example 17
Source File: NamingConventions.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Suggest names for a field. The name is computed from field's type * and possible prefixes or suffixes are added. * <p> * If the type of the field is <code>TypeName</code>, the prefix for field is <code>pre</code> * and the suffix for field is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code> * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code> * and <code>name</code>. * </p> * <p> * This method is affected by the following JavaCore options : {@link JavaCore#CODEASSIST_FIELD_PREFIXES}, * {@link JavaCore#CODEASSIST_FIELD_SUFFIXES} and for instance field and {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES}, * {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES} for static field. * </p> * <p> * For a complete description of these configurable options, see <code>getDefaultOptions</code>. * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>. * </p> * * @param javaProject project which contains the field. * @param packageName package of the field's type. * @param qualifiedTypeName field's type. * @param dim field's dimension (0 if the field is not an array). * @param modifiers field's modifiers as defined by the class * <code>Flags</code>. * @param excludedNames a list of names which cannot be suggested (already used names). * Can be <code>null</code> if there is no excluded names. * @return char[][] an array of names. * @see Flags * @see JavaCore#setOptions(java.util.Hashtable) * @see JavaCore#getDefaultOptions() * * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead * with {@link #VK_INSTANCE_FIELD} or {@link #VK_STATIC_FIELD} as variable kind. */ public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) { if(qualifiedTypeName == null || qualifiedTypeName.length == 0) return CharOperation.NO_CHAR_CHAR; char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.'); NamingRequestor requestor = new NamingRequestor(); InternalNamingConventions.suggestVariableNames( Flags.isStatic(modifiers) ? VK_STATIC_FIELD : VK_INSTANCE_FIELD, BK_TYPE_NAME, typeName, javaProject, dim, null, excludedNames, true, requestor); return requestor.getResults(); }
Example 18
Source File: PossibleMatch.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public char[][] getPackageName() { int length = this.compoundName.length; if (length <= 1) return CharOperation.NO_CHAR_CHAR; return CharOperation.subarray(this.compoundName, 0, length - 1); }
Example 19
Source File: PackageBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public PackageBinding(LookupEnvironment environment) { this(CharOperation.NO_CHAR_CHAR, null, environment); }
Example 20
Source File: PackageElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean isUnnamed() { PackageBinding binding = (PackageBinding)_binding; return binding.compoundName == CharOperation.NO_CHAR_CHAR; }