private Tag handleTag()

in core/src/main/java/org/adoptopenjdk/jitwatch/core/TagProcessor.java [107:175]


	private Tag handleTag(String line)
	{
		Tag result = null;

		if (DEBUG_LOGGING_TAGPROCESSOR)
		{
			logger.debug("Handling line: {}", line);
		}

		// closing tag
		if (line.charAt(1) == C_SLASH)
		{
			String closeName = line.substring(2, line.length() - 1);

			if (DEBUG_LOGGING_TAGPROCESSOR)
			{
				logger.debug("closeName:{}, currentTag:{}, topTag:{}", closeName,
						currentTag == null ? "null" : currentTag.getName(), topTag == null ? "null" : topTag.getName());
			}

			if (currentTag != null && closeName.equals(currentTag.getName()))
			{
				if (currentTag.getParent() == null)
				{
					result = currentTag;
				}
				else
				{
					currentTag = currentTag.getParent();
				}
				
				if (JITWatchConstants.TAG_PARSE.equals(currentTag.getName()) && !methodIDStack.isEmpty())
				{
					methodIDStack.pop();					
				}				
			}
			else if (S_FRAGMENT.equals(closeName))
			{
				topTag.setLast(true);
				result = topTag;
			}
		}
		else
		{
			boolean selfClosing = (line.charAt(line.length() - 2) == C_SLASH);

			int indexEndName = line.indexOf(C_SPACE);

			if (indexEndName == -1)
			{
				indexEndName = line.indexOf(C_CLOSE_ANGLE);

				if (indexEndName > 0)
				{
					if (selfClosing)
					{
						indexEndName = line.length() - 2;
					}
				}
			}

			if (indexEndName != -1)
			{
				result = processValidLine(line, indexEndName, selfClosing);
			}
		}

		return result;
	}