List of usage examples for org.eclipse.jdt.core Signature C_DOLLAR
char C_DOLLAR
To view the source code for org.eclipse.jdt.core Signature C_DOLLAR.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryTypeConverter.java
License:Open Source License
public BinaryTypeConverter(ProblemReporter problemReporter, CompilationResult compilationResult, HashSetOfCharArrayArray typeNames) { super(problemReporter, Signature.C_DOLLAR); this.compilationResult = compilationResult; this.typeNames = typeNames; }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.Util.java
License:Open Source License
private static void appendClassTypeSignature(char[] string, int start, StringBuffer buffer, boolean compact) { char c = string[start]; if (c != Signature.C_RESOLVED) { return;//ww w . ja va 2 s. c o m } int p = start + 1; int checkpoint = buffer.length(); while (true) { c = string[p]; switch (c) { case Signature.C_SEMICOLON: // all done return; case Signature.C_DOT: case '/': // erase package prefix if (compact) { buffer.setLength(checkpoint); } else { buffer.append('.'); } break; case Signature.C_DOLLAR: /** * Convert '$' in resolved type signatures into '.'. NOTE: This assumes that the type signature is an inner type * signature. This is true in most cases, but someone can define a non-inner type name containing a '$'. */ buffer.append('.'); break; default: buffer.append(c); } p++; } }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.Util.java
License:Open Source License
private static int appendClassTypeSignatureForAnchor(char[] string, int start, StringBuffer buffer) { // need a minimum 3 chars "Lx;" if (start >= string.length - 2) { throw new IllegalArgumentException(); }// ww w. j a v a 2 s . co m // must start in "L" or "Q" char c = string[start]; if (c != Signature.C_RESOLVED && c != Signature.C_UNRESOLVED) { throw new IllegalArgumentException(); } int p = start + 1; while (true) { if (p >= string.length) { throw new IllegalArgumentException(); } c = string[p]; switch (c) { case Signature.C_SEMICOLON: // all done return p; case Signature.C_GENERIC_START: int e = scanGenericEnd(string, p + 1); // once we hit type arguments there are no more package prefixes p = e; break; case Signature.C_DOT: buffer.append('.'); break; case '/': buffer.append('/'); break; case Signature.C_DOLLAR: // once we hit "$" there are no more package prefixes /** * Convert '$' in resolved type signatures into '.'. NOTE: This assumes that the type signature is an inner type * signature. This is true in most cases, but someone can define a non-inner type name containing a '$'. */ buffer.append('.'); break; default: buffer.append(c); } p++; } }
From source file:com.google.gwt.dev.javac.CachedCompilationUnit.java
License:Open Source License
public static void save(SourceFileCompilationUnit unit, OutputStream outputStream) throws Exception { DataOutputStream dos = null;//from w w w . j ava2 s. c om try { dos = new DataOutputStream(new BufferedOutputStream(outputStream)); // version dos.writeLong(CompilationUnitDiskCache.CACHE_VERSION); // simple stuff dos.writeLong(unit.getLastModified()); dos.writeUTF(unit.getDisplayLocation()); dos.writeUTF(unit.getTypeName()); dos.writeUTF(unit.getContentId().get()); dos.writeBoolean(unit.isSuperSource()); // compiled classes { Collection<CompiledClass> compiledClasses = unit.getCompiledClasses(); int size = compiledClasses.size(); dos.writeInt(size); if (size > 0) { // sort in enclosing order to be able to restore enclosing classes by name CompiledClass[] compiledClassesArray = compiledClasses .toArray(new CompiledClass[compiledClasses.size()]); Arrays.sort(compiledClassesArray, new Comparator<CompiledClass>() { public int compare(CompiledClass o1, CompiledClass o2) { int o1count = countMatches(o1.getInternalName(), Signature.C_DOLLAR); int o2count = countMatches(o2.getInternalName(), Signature.C_DOLLAR); return o1count - o2count; } }); // store for (CompiledClass compiledClass : compiledClassesArray) { // internal name dos.writeUTF(compiledClass.getInternalName()); // is local dos.writeBoolean(compiledClass.isLocal()); // bytes byte[] bytes = compiledClass.getBytes(); dos.writeInt(bytes.length); dos.write(bytes); // enclosing class, write the name only CompiledClass enclosingClass = compiledClass.getEnclosingClass(); String enclosingClassName = enclosingClass != null ? enclosingClass.getInternalName() : ""; dos.writeUTF(enclosingClassName); } } } // dependencies { Set<ContentId> dependencies = unit.getDependencies(); int size = dependencies.size(); dos.writeInt(size); if (size > 0) { for (ContentId contentId : dependencies) { dos.writeUTF(contentId.get()); } } } // JSNI methods { List<JsniMethod> jsniMethods = unit.getJsniMethods(); int size = jsniMethods.size(); dos.writeInt(size); if (size > 0) { for (JsniMethod jsniMethod : jsniMethods) { dos.writeUTF(jsniMethod.name()); JsFunction function = jsniMethod.function(); SourceInfo sourceInfo = function.getSourceInfo(); dos.writeInt(sourceInfo.getStartPos()); dos.writeInt(sourceInfo.getEndPos()); dos.writeInt(sourceInfo.getStartLine()); dos.writeUTF(function.toSource()); } } } // Method lookup { MethodArgNamesLookup methodArgs = unit.getMethodArgs(); MethodArgNamesLookup.save(methodArgs, dos); } } finally { IOUtils.closeQuietly(dos); } }
From source file:com.mountainminds.eclemma.internal.core.analysis.SignatureResolver.java
License:Open Source License
private static final boolean resolveType(final IType scope, final String identifier, final StringBuffer result) throws JavaModelException { final String[][] types = scope.resolveType(Signature.getTypeErasure(identifier)); if (types == null || types.length != 1) { return false; }//from w w w .ja va2 s . co m result.append(Signature.C_RESOLVED); final String qualifier = types[0][0]; if (qualifier.length() > 0) { replace(qualifier, Signature.C_DOT, SLASH, result); result.append(SLASH); } replace(types[0][1], Signature.C_DOT, Signature.C_DOLLAR, result); result.append(Signature.C_SEMICOLON); return true; }
From source file:org.eclipse.eclemma.internal.core.analysis.SignatureResolver.java
License:Open Source License
private static final boolean resolveType(final IType scope, final String identifier, final StringBuilder result) throws JavaModelException { final String[][] types = scope.resolveType(Signature.getTypeErasure(identifier)); if (types == null || types.length != 1) { return false; }//from w w w.ja v a 2 s . c om result.append(Signature.C_RESOLVED); final String qualifier = types[0][0]; if (qualifier.length() > 0) { replace(qualifier, Signature.C_DOT, SLASH, result); result.append(SLASH); } replace(types[0][1], Signature.C_DOT, Signature.C_DOLLAR, result); result.append(Signature.C_SEMICOLON); return true; }
From source file:org.eclipse.jem.internal.adapters.jdom.JDOMAdaptor.java
License:Open Source License
/** * Converts a type signature to a readable string. * * Uses Signature.toString(), then tries to undo bad replacement for inner classes. * /*from w ww . j a v a 2s .c o m*/ * Bug: 166226 [https://bugs.eclipse.org/bugs/show_bug.cgi?id=166226] * Update to use the erasure type from the signature in order to * tolerate JDK 5 generics. * */ public static String signatureToString(String signature) throws IllegalArgumentException { boolean hasDollar = (signature.indexOf(Signature.C_DOLLAR) != -1); //begin 166226 fix String result = Signature.getTypeErasure(signature); result = Signature.toString(result); //end 166226 fix if (hasDollar) { int newPos = result.lastIndexOf("."); //$NON-NLS-1$ if (newPos != -1) { result = result.substring(0, newPos) + "$" + result.substring(newPos + 1); //$NON-NLS-1$ } } return result; }
From source file:org.eclipse.recommenders.completion.rcp.utils.ProposalUtils.java
License:Open Source License
/** * Ensures that the separator of inner and outer types is always a dollar sign. * * <p>/*from ww w . jav a 2s . co m*/ * This is necessary, as JDT uses a dot rather than dollar sign to separate inner and outer type <em>if</em> the * outer type is parameterized. * </p> * * <p> * Examples: * </p> * * <ul> * <li><code>org.example.Outer$Inner<:java.lang.String></code> -> * <code>org.example.Outer$Inner<:java.lang.String></code></li> * <li><code>org.example.Outer<:java.lang.String>.Inner</code> -> * <code>org.example.Outer<:java.lang.String>$Inner</code></li> * <ul> */ private static char[] getBinaryTypeSignatureCopy(char[] parameterizedTypeSignature) { char[] binaryTypeSignature = Arrays.copyOf(parameterizedTypeSignature, parameterizedTypeSignature.length); int nextDot = -1; while ((nextDot = CharOperation.indexOf(Signature.C_DOT, binaryTypeSignature, nextDot + 1)) > 0) { if (binaryTypeSignature[nextDot - 1] == Signature.C_GENERIC_END) { binaryTypeSignature[nextDot] = Signature.C_DOLLAR; } } return binaryTypeSignature; }