Search in sources :

Example 6 with CharacterIterator

use of java.text.CharacterIterator in project intellij-community by JetBrains.

the class Strings method isCapitalized.

public static boolean isCapitalized(@NotNull String text, @NotNull TextRange range) {
    if (range.getLength() == 0)
        return false;
    CharacterIterator it = new StringCharacterIterator(text, range.getStartOffset() + 1, range.getEndOffset(), range.getStartOffset() + 1);
    boolean lowCase = true;
    for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
        lowCase = Character.isLowerCase(c);
    }
    return Character.isUpperCase(text.charAt(range.getStartOffset())) && lowCase;
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator)

Example 7 with CharacterIterator

use of java.text.CharacterIterator in project intellij-community by JetBrains.

the class StubBuildingVisitor method parseMethodSignature.

private MethodInfo parseMethodSignature(String signature, String[] exceptions) throws ClsFormatException {
    MethodInfo result = new MethodInfo();
    CharacterIterator iterator = new StringCharacterIterator(signature);
    result.typeParameters = SignatureParsing.parseTypeParametersDeclaration(iterator, myMapping);
    if (iterator.current() != '(')
        throw new ClsFormatException();
    iterator.next();
    if (iterator.current() == ')') {
        result.argTypes = ContainerUtil.emptyList();
    } else {
        result.argTypes = ContainerUtil.newSmartList();
        while (iterator.current() != ')' && iterator.current() != CharacterIterator.DONE) {
            result.argTypes.add(SignatureParsing.parseTypeString(iterator, myMapping));
        }
        if (iterator.current() != ')')
            throw new ClsFormatException();
    }
    iterator.next();
    result.returnType = SignatureParsing.parseTypeString(iterator, myMapping);
    result.throwTypes = null;
    while (iterator.current() == '^') {
        iterator.next();
        if (result.throwTypes == null)
            result.throwTypes = ContainerUtil.newSmartList();
        result.throwTypes.add(SignatureParsing.parseTypeString(iterator, myMapping));
    }
    if (exceptions != null && (result.throwTypes == null || exceptions.length > result.throwTypes.size())) {
        // a signature may be inconsistent with exception list - in this case, the more complete list takes precedence
        result.throwTypes = ContainerUtil.map(exceptions, name -> myMapping.fun(name));
    }
    return result;
}
Also used : ArrayUtil(com.intellij.util.ArrayUtil) Array(java.lang.reflect.Array) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) ModifierFlags(com.intellij.psi.impl.cache.ModifierFlags) PsiNameHelper(com.intellij.psi.PsiNameHelper) TypeInfo(com.intellij.psi.impl.cache.TypeInfo) Map(java.util.Map) Logger(com.intellij.openapi.diagnostic.Logger) Pair.pair(com.intellij.openapi.util.Pair.pair) LanguageLevel(com.intellij.pom.java.LanguageLevel) BitUtil.isSet(com.intellij.util.BitUtil.isSet) com.intellij.psi.impl.java.stubs(com.intellij.psi.impl.java.stubs) CharacterIterator(java.text.CharacterIterator) StringUtil(com.intellij.openapi.util.text.StringUtil) StringRef(com.intellij.util.io.StringRef) Set(java.util.Set) IOException(java.io.IOException) ClsFormatException(com.intellij.util.cls.ClsFormatException) StringCharacterIterator(java.text.StringCharacterIterator) CommonClassNames(com.intellij.psi.CommonClassNames) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) com.intellij.psi.impl.java.stubs.impl(com.intellij.psi.impl.java.stubs.impl) Function(com.intellij.util.Function) Pair(com.intellij.openapi.util.Pair) org.jetbrains.org.objectweb.asm(org.jetbrains.org.objectweb.asm) PsiFileStub(com.intellij.psi.stubs.PsiFileStub) StubElement(com.intellij.psi.stubs.StubElement) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) ClsFormatException(com.intellij.util.cls.ClsFormatException)

Example 8 with CharacterIterator

use of java.text.CharacterIterator in project jena by apache.

the class TurtleValidate method checkValidPrefixPart.

/* http://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar
     * [27]    qname           ::=     prefixName? ':' name?
     * [30]    nameStartChar   ::=     [A-Z] | "_" | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
     * [31]    nameChar        ::=     nameStartChar | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
     * [32]    name            ::=     nameStartChar nameChar*
     * [33]    prefixName      ::=     ( nameStartChar - '_' ) nameChar*
     */
protected static boolean checkValidPrefixPart(String s) {
    if (s.length() == 0)
        return true;
    CharacterIterator cIter = new StringCharacterIterator(s);
    char ch = cIter.first();
    if (!checkNameStartChar(ch))
        return false;
    if (// Can't start with _ (bnodes labels handled separately) 
    ch == '_')
        return false;
    return checkNameTail(cIter);
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator)

Example 9 with CharacterIterator

use of java.text.CharacterIterator in project jena by apache.

the class N3JenaWriterCommon method checkPrefixPart.

/* http://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar
     * [27]    qname           ::=     prefixName? ':' name?
     * [30]    nameStartChar   ::=     [A-Z] | "_" | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
     * [31]    nameChar        ::=     nameStartChar | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
     * [32]    name            ::=     nameStartChar nameChar*
     * [33]    prefixName      ::=     ( nameStartChar - '_' ) nameChar*
     */
protected static boolean checkPrefixPart(String s) {
    if (s.length() == 0)
        return true;
    CharacterIterator cIter = new StringCharacterIterator(s);
    char ch = cIter.first();
    if (!checkNameStartChar(ch))
        return false;
    if (// Can't start with _ (bnodes labels handled separately) 
    ch == '_')
        return false;
    return checkNameTail(cIter);
}
Also used : StringCharacterIterator(java.text.StringCharacterIterator) CharacterIterator(java.text.CharacterIterator) StringCharacterIterator(java.text.StringCharacterIterator)

Example 10 with CharacterIterator

use of java.text.CharacterIterator in project jdk8u_jdk by JetBrains.

the class DictionaryBasedBreakIterator method handleNext.

/**
     * This is the implementation function for next().
     */
@Override
protected int handleNext() {
    CharacterIterator text = getText();
    // and possibly regenerate the cache
    if (cachedBreakPositions == null || positionInCache == cachedBreakPositions.length - 1) {
        // start by using the inherited handleNext() to find a tentative return
        // value.   dictionaryCharCount tells us how many dictionary characters
        // we passed over on our way to the tentative return value
        int startPos = text.getIndex();
        dictionaryCharCount = 0;
        int result = super.handleNext();
        // for the new range
        if (dictionaryCharCount > 1 && result - startPos > 1) {
            divideUpDictionaryRange(startPos, result);
        } else // otherwise, the value we got back from the inherited fuction
        // is our return value, and we can dump the cache
        {
            cachedBreakPositions = null;
            return result;
        }
    }
    // and return it
    if (cachedBreakPositions != null) {
        ++positionInCache;
        text.setIndex(cachedBreakPositions[positionInCache]);
        return cachedBreakPositions[positionInCache];
    }
    // SHOULD NEVER GET HERE!
    return -9999;
}
Also used : CharacterIterator(java.text.CharacterIterator)

Aggregations

CharacterIterator (java.text.CharacterIterator)33 StringCharacterIterator (java.text.StringCharacterIterator)28 Nullable (org.jetbrains.annotations.Nullable)3 ClsFormatException (com.intellij.util.cls.ClsFormatException)2 ArrayList (java.util.ArrayList)2 Logger (com.intellij.openapi.diagnostic.Logger)1 Pair (com.intellij.openapi.util.Pair)1 Pair.pair (com.intellij.openapi.util.Pair.pair)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 CommonClassNames (com.intellij.psi.CommonClassNames)1 PsiNameHelper (com.intellij.psi.PsiNameHelper)1 ModifierFlags (com.intellij.psi.impl.cache.ModifierFlags)1 TypeInfo (com.intellij.psi.impl.cache.TypeInfo)1 com.intellij.psi.impl.java.stubs (com.intellij.psi.impl.java.stubs)1 com.intellij.psi.impl.java.stubs.impl (com.intellij.psi.impl.java.stubs.impl)1 PsiFileStub (com.intellij.psi.stubs.PsiFileStub)1 StubElement (com.intellij.psi.stubs.StubElement)1 ArrayUtil (com.intellij.util.ArrayUtil)1