List of usage examples for org.eclipse.jdt.internal.compiler.parser ScannerHelper isJavaIdentifierPart
public static boolean isJavaIdentifierPart(char c)
From source file:com.bsiag.eclipse.jdt.java.formatter.CommentsPreparator.java
License:Open Source License
private void addSubstituteWraps() { int commentStart = this.ctm.get(0).originalStart; for (int i = 1; i < this.ctm.size() - 1; i++) { Token token = this.ctm.get(i); for (int pos = token.originalStart + 1; pos < token.originalEnd; pos++) { if (this.noSubstituteWrapping[pos - commentStart]) continue; char c = this.ctm.charAt(pos); if (!ScannerHelper.isJavaIdentifierPart(c) && c != '@'/* wrapping on @ would create a javadoc tag */) { this.ctm.get(tokenStartingAt(pos)).setWrapPolicy(WrapPolicy.SUBSTITUTE_ONLY); this.ctm.get(tokenStartingAt(pos + 1)).setWrapPolicy(WrapPolicy.SUBSTITUTE_ONLY); }/*www .j a v a 2 s .c om*/ } } }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
public void finishUp() { this.tm.traverse(0, new TokenTraverser() { boolean isPreviousJIDP = false; @Override/*from w ww. j a v a2 s .co m*/ protected boolean token(Token token, int index) { // put space between consecutive keywords, numbers or identifiers char c = SpacePreparator.this.tm.charAt(token.originalStart); boolean isJIDP = ScannerHelper.isJavaIdentifierPart(c); if ((isJIDP || c == '@') && this.isPreviousJIDP) getPrevious().spaceAfter(); this.isPreviousJIDP = isJIDP; switch (token.tokenType) { case TokenNamePLUS: if (getNext().tokenType == TokenNamePLUS || getNext().tokenType == TokenNamePLUS_PLUS) token.spaceAfter(); break; case TokenNameMINUS: if (getNext().tokenType == TokenNameMINUS || getNext().tokenType == TokenNameMINUS_MINUS) token.spaceAfter(); break; } return true; } }); }
From source file:com.codenvy.ide.ext.java.server.core.search.SearchPattern.java
License:Open Source License
private static boolean validateCamelCasePattern(String stringPattern) { if (stringPattern == null) return true; // verify sting pattern validity int length = stringPattern.length(); boolean validCamelCase = true; boolean lowerCamelCase = false; int uppercase = 0; for (int i = 0; i < length && validCamelCase; i++) { char ch = stringPattern.charAt(i); validCamelCase = i == 0 ? ScannerHelper.isJavaIdentifierStart(ch) : ScannerHelper.isJavaIdentifierPart(ch); // at least one uppercase character is need in CamelCase pattern // (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=136313) if (ScannerHelper.isUpperCase(ch)) uppercase++;/* w w w .ja va 2 s . co m*/ if (i == 0) lowerCamelCase = uppercase == 0; } if (validCamelCase) { validCamelCase = lowerCamelCase ? uppercase > 0 : uppercase > 1; } return validCamelCase; }
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryMethod.java
License:Open Source License
private boolean isOpenParenForMethod(String javaDoc, String methodName, int index) { /*/*from www . ja v a 2s . com*/ * Annotations can have parameters associated with them, so we need to validate that this parameter list is * actually for the method. Determine this by scanning backwards from where the paren was seen, skipping over * HTML tags to find the identifier that precedes the paren, and then matching that identifier against the * method's name. */ boolean scanningTag = false; int endIndex = 0; while (--index > methodName.length()) { char previousChar = javaDoc.charAt(index); if (endIndex > 0) { if (!ScannerHelper.isJavaIdentifierPart(previousChar) || !ScannerHelper.isJavaIdentifierStart(previousChar)) return methodName.equals(javaDoc.substring(index + 1, endIndex)); } else if (!scanningTag) { if (previousChar == '>') scanningTag = true; else if (ScannerHelper.isJavaIdentifierPart(previousChar) || ScannerHelper.isJavaIdentifierStart(previousChar)) endIndex = index + 1; } else if (previousChar == '<') // We are only matching angle brackets here, without any other validation of the tags. scanningTag = false; } return false; }