LinkInTrace (@NotNull final String line) { final PyFilesStateMachine quoteMachine = new PyFilesStateMachine(true); final PyFilesStateMachine spaceMachine = new PyFilesStateMachine(false); final char[] chars = line.toCharArray(); for (int i = 0; i < chars.length; i++) { final char nextChar = chars[i]; if (quoteMachine.addChar(nextChar, i)) { return createLinkInTrace(quoteMachine); } if (spaceMachine.addChar(nextChar, i)) { return createLinkInTrace(spaceMachine); } } // Tell all machines file is ended if (quoteMachine.endLine()) { return createLinkInTrace(quoteMachine); } if (spaceMachine.endLine()) { return createLinkInTrace(spaceMachine); } return null; }