├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── a4455jkjh │ │ └── textview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── a.txt │ │ └── monospace.ttf │ ├── java │ │ ├── com │ │ │ └── a4455jkjh │ │ │ │ ├── textview │ │ │ │ ├── App.java │ │ │ │ └── MainActivity.java │ │ │ │ └── view │ │ │ │ ├── EditText.java │ │ │ │ ├── EditorSettings.java │ │ │ │ ├── Highlighting.java │ │ │ │ ├── Span.java │ │ │ │ ├── TextStyle.java │ │ │ │ ├── TextView.java │ │ │ │ ├── UndoManager.java │ │ │ │ └── highlighting │ │ │ │ ├── SmaliHighlighting.java │ │ │ │ └── smali │ │ │ │ └── SmaliLexer.java │ │ └── org │ │ │ └── antlr │ │ │ └── v4 │ │ │ └── runtime │ │ │ ├── ANTLRErrorListener.java │ │ │ ├── ANTLRErrorStrategy.java │ │ │ ├── ANTLRFileStream.java │ │ │ ├── ANTLRInputStream.java │ │ │ ├── BailErrorStrategy.java │ │ │ ├── BaseErrorListener.java │ │ │ ├── BufferedTokenStream.java │ │ │ ├── CharStream.java │ │ │ ├── CharStreams.java │ │ │ ├── CodePointBuffer.java │ │ │ ├── CodePointCharStream.java │ │ │ ├── CommonToken.java │ │ │ ├── CommonTokenFactory.java │ │ │ ├── CommonTokenStream.java │ │ │ ├── ConsoleErrorListener.java │ │ │ ├── DefaultErrorStrategy.java │ │ │ ├── DiagnosticErrorListener.java │ │ │ ├── FailedPredicateException.java │ │ │ ├── InputMismatchException.java │ │ │ ├── IntStream.java │ │ │ ├── InterpreterRuleContext.java │ │ │ ├── Lexer.java │ │ │ ├── LexerInterpreter.java │ │ │ ├── LexerNoViableAltException.java │ │ │ ├── ListTokenSource.java │ │ │ ├── NoViableAltException.java │ │ │ ├── Parser.java │ │ │ ├── ParserInterpreter.java │ │ │ ├── ParserRuleContext.java │ │ │ ├── ProxyErrorListener.java │ │ │ ├── RecognitionException.java │ │ │ ├── Recognizer.java │ │ │ ├── RuleContext.java │ │ │ ├── RuleContextWithAltNum.java │ │ │ ├── RuntimeMetaData.java │ │ │ ├── Scanner.java │ │ │ ├── ScannerImpl.java │ │ │ ├── Token.java │ │ │ ├── TokenFactory.java │ │ │ ├── TokenSource.java │ │ │ ├── TokenStream.java │ │ │ ├── TokenStreamRewriter.java │ │ │ ├── UnbufferedCharStream.java │ │ │ ├── UnbufferedTokenStream.java │ │ │ ├── Vocabulary.java │ │ │ ├── VocabularyImpl.java │ │ │ ├── WritableToken.java │ │ │ ├── atn │ │ │ ├── ATN.java │ │ │ ├── ATNConfig.java │ │ │ ├── ATNConfigSet.java │ │ │ ├── ATNDeserializationOptions.java │ │ │ ├── ATNDeserializer.java │ │ │ ├── ATNSerializer.java │ │ │ ├── ATNSimulator.java │ │ │ ├── ATNState.java │ │ │ ├── ATNType.java │ │ │ ├── AbstractPredicateTransition.java │ │ │ ├── ActionTransition.java │ │ │ ├── AmbiguityInfo.java │ │ │ ├── ArrayPredictionContext.java │ │ │ ├── AtomTransition.java │ │ │ ├── BasicBlockStartState.java │ │ │ ├── BasicState.java │ │ │ ├── BlockEndState.java │ │ │ ├── BlockStartState.java │ │ │ ├── CodePointTransitions.java │ │ │ ├── ContextSensitivityInfo.java │ │ │ ├── DecisionEventInfo.java │ │ │ ├── DecisionInfo.java │ │ │ ├── DecisionState.java │ │ │ ├── EmptyPredictionContext.java │ │ │ ├── EpsilonTransition.java │ │ │ ├── ErrorInfo.java │ │ │ ├── LL1Analyzer.java │ │ │ ├── LexerATNConfig.java │ │ │ ├── LexerATNSimulator.java │ │ │ ├── LexerAction.java │ │ │ ├── LexerActionExecutor.java │ │ │ ├── LexerActionType.java │ │ │ ├── LexerChannelAction.java │ │ │ ├── LexerCustomAction.java │ │ │ ├── LexerIndexedCustomAction.java │ │ │ ├── LexerModeAction.java │ │ │ ├── LexerMoreAction.java │ │ │ ├── LexerPopModeAction.java │ │ │ ├── LexerPushModeAction.java │ │ │ ├── LexerSkipAction.java │ │ │ ├── LexerTypeAction.java │ │ │ ├── LookaheadEventInfo.java │ │ │ ├── LoopEndState.java │ │ │ ├── NotSetTransition.java │ │ │ ├── OrderedATNConfigSet.java │ │ │ ├── ParseInfo.java │ │ │ ├── ParserATNSimulator.java │ │ │ ├── PlusBlockStartState.java │ │ │ ├── PlusLoopbackState.java │ │ │ ├── PrecedencePredicateTransition.java │ │ │ ├── PredicateEvalInfo.java │ │ │ ├── PredicateTransition.java │ │ │ ├── PredictionContext.java │ │ │ ├── PredictionContextCache.java │ │ │ ├── PredictionMode.java │ │ │ ├── ProfilingATNSimulator.java │ │ │ ├── RangeTransition.java │ │ │ ├── RuleStartState.java │ │ │ ├── RuleStopState.java │ │ │ ├── RuleTransition.java │ │ │ ├── SemanticContext.java │ │ │ ├── SetTransition.java │ │ │ ├── SingletonPredictionContext.java │ │ │ ├── StarBlockStartState.java │ │ │ ├── StarLoopEntryState.java │ │ │ ├── StarLoopbackState.java │ │ │ ├── TokensStartState.java │ │ │ ├── Transition.java │ │ │ └── WildcardTransition.java │ │ │ ├── dfa │ │ │ ├── DFA.java │ │ │ ├── DFASerializer.java │ │ │ ├── DFAState.java │ │ │ └── LexerDFASerializer.java │ │ │ ├── misc │ │ │ ├── AbstractEqualityComparator.java │ │ │ ├── Array2DHashSet.java │ │ │ ├── DoubleKeyMap.java │ │ │ ├── EqualityComparator.java │ │ │ ├── FlexibleHashMap.java │ │ │ ├── IntSet.java │ │ │ ├── IntegerList.java │ │ │ ├── IntegerStack.java │ │ │ ├── InterpreterDataReader.java │ │ │ ├── Interval.java │ │ │ ├── IntervalSet.java │ │ │ ├── LogManager.java │ │ │ ├── MultiMap.java │ │ │ ├── MurmurHash.java │ │ │ ├── NotNull.java │ │ │ ├── ObjectEqualityComparator.java │ │ │ ├── OrderedHashSet.java │ │ │ ├── Pair.java │ │ │ ├── ParseCancellationException.java │ │ │ ├── Predicate.java │ │ │ ├── TestRig.java │ │ │ ├── Triple.java │ │ │ └── Utils.java │ │ │ └── tree │ │ │ ├── AbstractParseTreeVisitor.java │ │ │ ├── ErrorNode.java │ │ │ ├── ErrorNodeImpl.java │ │ │ ├── IterativeParseTreeWalker.java │ │ │ ├── ParseTree.java │ │ │ ├── ParseTreeListener.java │ │ │ ├── ParseTreeProperty.java │ │ │ ├── ParseTreeVisitor.java │ │ │ ├── ParseTreeWalker.java │ │ │ ├── RuleNode.java │ │ │ ├── SyntaxTree.java │ │ │ ├── TerminalNode.java │ │ │ ├── TerminalNodeImpl.java │ │ │ ├── Tree.java │ │ │ ├── Trees.java │ │ │ ├── pattern │ │ │ ├── Chunk.java │ │ │ ├── ParseTreeMatch.java │ │ │ ├── ParseTreePattern.java │ │ │ ├── ParseTreePatternMatcher.java │ │ │ ├── RuleTagToken.java │ │ │ ├── TagChunk.java │ │ │ ├── TextChunk.java │ │ │ └── TokenTagToken.java │ │ │ └── xpath │ │ │ ├── XPath.java │ │ │ ├── XPathElement.java │ │ │ ├── XPathLexer.java │ │ │ ├── XPathLexerErrorListener.java │ │ │ ├── XPathRuleAnywhereElement.java │ │ │ ├── XPathRuleElement.java │ │ │ ├── XPathTokenAnywhereElement.java │ │ │ ├── XPathTokenElement.java │ │ │ ├── XPathWildcardAnywhereElement.java │ │ │ └── XPathWildcardElement.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── menu │ │ ├── editor_context.xml │ │ └── main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── a4455jkjh │ └── textview │ └── ExampleUnitTest.java ├── build.gradle ├── dom ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── libs │ └── ecj.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── eclipse │ │ └── jdt │ │ └── core │ │ └── dom │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── eclipse │ │ │ ├── core │ │ │ ├── commands │ │ │ │ ├── ExecutionException.java │ │ │ │ ├── common │ │ │ │ │ └── CommandException.java │ │ │ │ ├── operations │ │ │ │ │ ├── AbstractOperation.java │ │ │ │ │ ├── DefaultOperationHistory.java │ │ │ │ │ ├── IAdvancedUndoableOperation.java │ │ │ │ │ ├── ICompositeOperation.java │ │ │ │ │ ├── IContextReplacingOperation.java │ │ │ │ │ ├── IOperationApprover.java │ │ │ │ │ ├── IOperationApprover2.java │ │ │ │ │ ├── IOperationHistory.java │ │ │ │ │ ├── IOperationHistoryListener.java │ │ │ │ │ ├── IUndoContext.java │ │ │ │ │ ├── IUndoableOperation.java │ │ │ │ │ ├── ObjectUndoContext.java │ │ │ │ │ ├── OperationHistoryEvent.java │ │ │ │ │ ├── OperationHistoryFactory.java │ │ │ │ │ ├── OperationStatus.java │ │ │ │ │ └── UndoContext.java │ │ │ │ └── util │ │ │ │ │ └── Tracing.java │ │ │ ├── internal │ │ │ │ ├── commands │ │ │ │ │ └── operations │ │ │ │ │ │ └── GlobalUndoContext.java │ │ │ │ └── runtime │ │ │ │ │ ├── LocalizationUtils.java │ │ │ │ │ └── PrintStackUtil.java │ │ │ └── runtime │ │ │ │ ├── Assert.java │ │ │ │ ├── AssertionFailedException.java │ │ │ │ ├── CoreException.java │ │ │ │ ├── IAdaptable.java │ │ │ │ ├── IProgressMonitor.java │ │ │ │ ├── ISafeRunnable.java │ │ │ │ ├── IStatus.java │ │ │ │ ├── ListenerList.java │ │ │ │ ├── OperationCanceledException.java │ │ │ │ ├── SafeRunner.java │ │ │ │ └── Status.java │ │ │ ├── jdt │ │ │ ├── core │ │ │ │ ├── JavaCore.java │ │ │ │ └── dom │ │ │ │ │ ├── AST.java │ │ │ │ │ ├── ASTConverter.java │ │ │ │ │ ├── ASTMatcher.java │ │ │ │ │ ├── ASTNode.java │ │ │ │ │ ├── ASTParser.java │ │ │ │ │ ├── ASTRecoveryPropagator.java │ │ │ │ │ ├── ASTSyntaxErrorPropagator.java │ │ │ │ │ ├── ASTVisitor.java │ │ │ │ │ ├── AbstractTypeDeclaration.java │ │ │ │ │ ├── AnnotatableType.java │ │ │ │ │ ├── Annotation.java │ │ │ │ │ ├── AnnotationTypeDeclaration.java │ │ │ │ │ ├── AnnotationTypeMemberDeclaration.java │ │ │ │ │ ├── AnonymousClassDeclaration.java │ │ │ │ │ ├── ArrayAccess.java │ │ │ │ │ ├── ArrayCreation.java │ │ │ │ │ ├── ArrayInitializer.java │ │ │ │ │ ├── ArrayType.java │ │ │ │ │ ├── AssertStatement.java │ │ │ │ │ ├── Assignment.java │ │ │ │ │ ├── Block.java │ │ │ │ │ ├── BlockComment.java │ │ │ │ │ ├── BodyDeclaration.java │ │ │ │ │ ├── BooleanLiteral.java │ │ │ │ │ ├── BreakStatement.java │ │ │ │ │ ├── CastExpression.java │ │ │ │ │ ├── CatchClause.java │ │ │ │ │ ├── CharacterLiteral.java │ │ │ │ │ ├── ChildListPropertyDescriptor.java │ │ │ │ │ ├── ChildPropertyDescriptor.java │ │ │ │ │ ├── ClassInstanceCreation.java │ │ │ │ │ ├── Comment.java │ │ │ │ │ ├── CompilationUnit.java │ │ │ │ │ ├── CompilationUnitResolver.java │ │ │ │ │ ├── ConditionalExpression.java │ │ │ │ │ ├── ConstructorInvocation.java │ │ │ │ │ ├── ContinueStatement.java │ │ │ │ │ ├── CreationReference.java │ │ │ │ │ ├── DefaultASTVisitor.java │ │ │ │ │ ├── DefaultCommentMapper.java │ │ │ │ │ ├── Dimension.java │ │ │ │ │ ├── DoStatement.java │ │ │ │ │ ├── DocCommentParser.java │ │ │ │ │ ├── EmptyStatement.java │ │ │ │ │ ├── EnhancedForStatement.java │ │ │ │ │ ├── EnumConstantDeclaration.java │ │ │ │ │ ├── EnumDeclaration.java │ │ │ │ │ ├── Expression.java │ │ │ │ │ ├── ExpressionMethodReference.java │ │ │ │ │ ├── ExpressionStatement.java │ │ │ │ │ ├── FieldAccess.java │ │ │ │ │ ├── FieldDeclaration.java │ │ │ │ │ ├── ForStatement.java │ │ │ │ │ ├── IDocElement.java │ │ │ │ │ ├── IExtendedModifier.java │ │ │ │ │ ├── IfStatement.java │ │ │ │ │ ├── ImportDeclaration.java │ │ │ │ │ ├── InfixExpression.java │ │ │ │ │ ├── Initializer.java │ │ │ │ │ ├── InstanceofExpression.java │ │ │ │ │ ├── IntersectionType.java │ │ │ │ │ ├── Javadoc.java │ │ │ │ │ ├── LabeledStatement.java │ │ │ │ │ ├── LambdaExpression.java │ │ │ │ │ ├── LineComment.java │ │ │ │ │ ├── MarkerAnnotation.java │ │ │ │ │ ├── MemberRef.java │ │ │ │ │ ├── MemberValuePair.java │ │ │ │ │ ├── Message.java │ │ │ │ │ ├── MethodDeclaration.java │ │ │ │ │ ├── MethodInvocation.java │ │ │ │ │ ├── MethodRef.java │ │ │ │ │ ├── MethodRefParameter.java │ │ │ │ │ ├── MethodReference.java │ │ │ │ │ ├── Modifier.java │ │ │ │ │ ├── Name.java │ │ │ │ │ ├── NameQualifiedType.java │ │ │ │ │ ├── NodeEventHandler.java │ │ │ │ │ ├── NormalAnnotation.java │ │ │ │ │ ├── NullLiteral.java │ │ │ │ │ ├── NumberLiteral.java │ │ │ │ │ ├── PackageDeclaration.java │ │ │ │ │ ├── ParameterizedType.java │ │ │ │ │ ├── ParenthesizedExpression.java │ │ │ │ │ ├── PostfixExpression.java │ │ │ │ │ ├── PrefixExpression.java │ │ │ │ │ ├── PrimitiveType.java │ │ │ │ │ ├── QualifiedName.java │ │ │ │ │ ├── QualifiedType.java │ │ │ │ │ ├── ReturnStatement.java │ │ │ │ │ ├── SimpleName.java │ │ │ │ │ ├── SimplePropertyDescriptor.java │ │ │ │ │ ├── SimpleType.java │ │ │ │ │ ├── SingleMemberAnnotation.java │ │ │ │ │ ├── SingleVariableDeclaration.java │ │ │ │ │ ├── Statement.java │ │ │ │ │ ├── StringLiteral.java │ │ │ │ │ ├── StructuralPropertyDescriptor.java │ │ │ │ │ ├── SuperConstructorInvocation.java │ │ │ │ │ ├── SuperFieldAccess.java │ │ │ │ │ ├── SuperMethodInvocation.java │ │ │ │ │ ├── SuperMethodReference.java │ │ │ │ │ ├── SwitchCase.java │ │ │ │ │ ├── SwitchStatement.java │ │ │ │ │ ├── SynchronizedStatement.java │ │ │ │ │ ├── TagElement.java │ │ │ │ │ ├── TextElement.java │ │ │ │ │ ├── ThisExpression.java │ │ │ │ │ ├── ThrowStatement.java │ │ │ │ │ ├── TryStatement.java │ │ │ │ │ ├── Type.java │ │ │ │ │ ├── TypeDeclaration.java │ │ │ │ │ ├── TypeDeclarationStatement.java │ │ │ │ │ ├── TypeLiteral.java │ │ │ │ │ ├── TypeMethodReference.java │ │ │ │ │ ├── TypeParameter.java │ │ │ │ │ ├── UnionType.java │ │ │ │ │ ├── VariableDeclaration.java │ │ │ │ │ ├── VariableDeclarationExpression.java │ │ │ │ │ ├── VariableDeclarationFragment.java │ │ │ │ │ ├── VariableDeclarationStatement.java │ │ │ │ │ ├── WhileStatement.java │ │ │ │ │ └── WildcardType.java │ │ │ └── internal │ │ │ │ └── core │ │ │ │ ├── BasicCompilationUnit.java │ │ │ │ └── util │ │ │ │ ├── CodeSnippetParsingUtil.java │ │ │ │ ├── CommentRecorderParser.java │ │ │ │ └── RecordedParsingInformation.java │ │ │ ├── jface │ │ │ └── text │ │ │ │ ├── AbstractDocument.java │ │ │ │ ├── AbstractLineTracker.java │ │ │ │ ├── BadLocationException.java │ │ │ │ ├── BadPartitioningException.java │ │ │ │ ├── BadPositionCategoryException.java │ │ │ │ ├── ConfigurableLineTracker.java │ │ │ │ ├── CopyOnWriteTextStore.java │ │ │ │ ├── DefaultLineTracker.java │ │ │ │ ├── DefaultPositionUpdater.java │ │ │ │ ├── Document.java │ │ │ │ ├── DocumentAdapter.java │ │ │ │ ├── DocumentClone.java │ │ │ │ ├── DocumentEvent.java │ │ │ │ ├── DocumentPartitioningChangedEvent.java │ │ │ │ ├── DocumentRewriteSession.java │ │ │ │ ├── DocumentRewriteSessionEvent.java │ │ │ │ ├── DocumentRewriteSessionType.java │ │ │ │ ├── FindReplaceDocumentAdapter.java │ │ │ │ ├── GapTextStore.java │ │ │ │ ├── IDocument.java │ │ │ │ ├── IDocumentExtension.java │ │ │ │ ├── IDocumentExtension2.java │ │ │ │ ├── IDocumentExtension3.java │ │ │ │ ├── IDocumentExtension4.java │ │ │ │ ├── IDocumentListener.java │ │ │ │ ├── IDocumentPartitioner.java │ │ │ │ ├── IDocumentPartitionerExtension.java │ │ │ │ ├── IDocumentPartitionerExtension2.java │ │ │ │ ├── IDocumentPartitionerExtension3.java │ │ │ │ ├── IDocumentPartitioningListener.java │ │ │ │ ├── IDocumentPartitioningListenerExtension.java │ │ │ │ ├── IDocumentPartitioningListenerExtension2.java │ │ │ │ ├── IDocumentRewriteSessionListener.java │ │ │ │ ├── ILineTracker.java │ │ │ │ ├── ILineTrackerExtension.java │ │ │ │ ├── IPositionUpdater.java │ │ │ │ ├── IRegion.java │ │ │ │ ├── IRepairableDocument.java │ │ │ │ ├── IRepairableDocumentExtension.java │ │ │ │ ├── ITextStore.java │ │ │ │ ├── ITypedRegion.java │ │ │ │ ├── Line.java │ │ │ │ ├── ListLineTracker.java │ │ │ │ ├── Position.java │ │ │ │ ├── Region.java │ │ │ │ ├── TextChangeListener.java │ │ │ │ ├── TextChangingEvent.java │ │ │ │ ├── TextMessages.java │ │ │ │ ├── TextMessages.properties │ │ │ │ ├── TextUtilities.java │ │ │ │ ├── TreeLineTracker.java │ │ │ │ └── TypedRegion.java │ │ │ └── text │ │ │ ├── edits │ │ │ ├── CopySourceEdit.java │ │ │ ├── CopyTargetEdit.java │ │ │ ├── CopyingRangeMarker.java │ │ │ ├── DeleteEdit.java │ │ │ ├── EditDocument.java │ │ │ ├── ISourceModifier.java │ │ │ ├── InsertEdit.java │ │ │ ├── MalformedTreeException.java │ │ │ ├── Messages.properties │ │ │ ├── MoveSourceEdit.java │ │ │ ├── MoveTargetEdit.java │ │ │ ├── MultiTextEdit.java │ │ │ ├── RangeMarker.java │ │ │ ├── ReplaceEdit.java │ │ │ ├── TextEdit.java │ │ │ ├── TextEditCopier.java │ │ │ ├── TextEditMessages.java │ │ │ ├── TextEditProcessor.java │ │ │ ├── TextEditVisitor.java │ │ │ ├── UndoCollector.java │ │ │ └── UndoEdit.java │ │ │ └── undo │ │ │ ├── DocumentUndoEvent.java │ │ │ ├── DocumentUndoManager.java │ │ │ ├── DocumentUndoManagerRegistry.java │ │ │ ├── IDocumentUndoListener.java │ │ │ ├── IDocumentUndoManager.java │ │ │ ├── UndoMessages.java │ │ │ └── UndoMessages.properties │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── org │ └── eclipse │ └── jdt │ └── core │ └── dom │ └── ExampleUnitTest.java ├── formatter ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── eclipse │ │ └── jdt │ │ └── core │ │ └── formatter │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── eclipse │ │ │ └── jdt │ │ │ ├── core │ │ │ └── formatter │ │ │ │ ├── CodeFormatter.java │ │ │ │ ├── DefaultCodeFormatterConstants.java │ │ │ │ ├── IndentManipulation.java │ │ │ │ ├── messages.properties │ │ │ │ └── package.html │ │ │ └── internal │ │ │ └── formatter │ │ │ ├── CommentsPreparator.java │ │ │ ├── DefaultCodeFormatter.java │ │ │ ├── DefaultCodeFormatterOptions.java │ │ │ ├── LineBreaksPreparator.java │ │ │ ├── SpacePreparator.java │ │ │ ├── TextEditsBuilder.java │ │ │ ├── Token.java │ │ │ ├── TokenManager.java │ │ │ ├── TokenTraverser.java │ │ │ └── linewrap │ │ │ ├── CommentWrapExecutor.java │ │ │ ├── FieldAligner.java │ │ │ ├── WrapExecutor.java │ │ │ └── WrapPreparator.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── org │ └── eclipse │ └── jdt │ └── core │ └── formatter │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TextView -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | defaultConfig { 7 | applicationId "com.a4455jkjh.textview" 8 | minSdkVersion 15 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation project(':formatter') 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/a4455jkjh/textview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.textview; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("com.a4455jkjh.textview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/assets/monospace.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/assets/monospace.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/a4455jkjh/textview/App.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.textview; 2 | 3 | import android.app.Application; 4 | 5 | import com.a4455jkjh.view.EditorSettings; 6 | 7 | public class App extends Application { 8 | @Override 9 | public void onCreate() { 10 | super.onCreate(); 11 | EditorSettings.init(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/a4455jkjh/textview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.textview; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | 8 | import com.a4455jkjh.view.EditText; 9 | import com.a4455jkjh.view.TextView; 10 | import com.a4455jkjh.view.highlighting.SmaliHighlighting; 11 | 12 | public class MainActivity extends Activity { 13 | private EditText textView; 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | textView = new EditText(this); 18 | textView.setHighlighting(new SmaliHighlighting()); 19 | setContentView(textView); 20 | } 21 | 22 | @Override 23 | public boolean onCreateOptionsMenu(Menu menu) { 24 | getMenuInflater().inflate(R.menu.main,menu); 25 | return super.onCreateOptionsMenu(menu); 26 | } 27 | 28 | @Override 29 | public boolean onPrepareOptionsMenu(Menu menu) { 30 | menu.findItem(R.id.undo).setEnabled(textView.undoable()); 31 | menu.findItem(R.id.redo).setEnabled(textView.redoable()); 32 | return super.onPrepareOptionsMenu(menu); 33 | } 34 | 35 | @Override 36 | public boolean onOptionsItemSelected(MenuItem item) { 37 | switch (item.getItemId()){ 38 | case R.id.undo: 39 | textView.undo(); 40 | break; 41 | case R.id.redo: 42 | textView.redo(); 43 | break; 44 | default: 45 | return super.onOptionsItemSelected(item); 46 | } 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/a4455jkjh/view/EditorSettings.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetManager; 5 | import android.content.res.Resources; 6 | import android.graphics.Paint; 7 | import android.graphics.Typeface; 8 | import com.a4455jkjh.textview.R; 9 | 10 | import java.io.ByteArrayOutputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | 14 | public class EditorSettings { 15 | public static Typeface typeface; 16 | public static boolean showLineNumber; 17 | public static boolean drawCaretLine; 18 | private static float sp; 19 | public static String text_text; 20 | 21 | public static float getTextSize(int textSize) { 22 | return textSize * sp; 23 | } 24 | public static Paint newPaint(int textSize) { 25 | Paint p = new Paint(); 26 | p.setAntiAlias(true); 27 | p.setTypeface(typeface); 28 | float size = textSize * sp; 29 | p.setTextSize(size); 30 | p.setStrokeWidth(sp); 31 | return p; 32 | } 33 | public static void init(Context ctx) { 34 | Resources res = ctx.getResources(); 35 | sp = res.getDimension(R.dimen.sp); 36 | AssetManager a = ctx.getAssets(); 37 | try { 38 | InputStream i = a.open("a.txt"); 39 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 40 | byte[] bytes = new byte[1024]; 41 | int num; 42 | while ((num = i.read(bytes)) > 0) { 43 | baos.write(bytes, 0, num); 44 | } 45 | text_text = baos.toString(); 46 | i.close(); 47 | baos.reset(); 48 | baos.close(); 49 | } catch (IOException e) { 50 | text_text = e.toString(); 51 | e.printStackTrace(); 52 | } 53 | } 54 | static { 55 | typeface = Typeface.MONOSPACE; 56 | showLineNumber = true; 57 | drawCaretLine = true; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/a4455jkjh/view/Highlighting.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.view; 2 | 3 | public interface Highlighting { 4 | Span highlighhting(String code); 5 | public static class DefaultHighlighting implements Highlighting { 6 | @Override 7 | public Span highlighhting(String code) { 8 | return Span.DEFAULT_SPAN; 9 | } 10 | private DefaultHighlighting(){} 11 | public static Highlighting INSTANCE = new DefaultHighlighting(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/ANTLRFileStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | import org.antlr.v4.runtime.misc.Utils; 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * This is an {@link ANTLRInputStream} that is loaded from a file all at once 14 | * when you construct the object. 15 | * 16 | * @deprecated as of 4.7 Please use {@link CharStreams} interface. 17 | */ 18 | public class ANTLRFileStream extends ANTLRInputStream { 19 | protected String fileName; 20 | 21 | public ANTLRFileStream(String fileName) throws IOException { 22 | this(fileName, null); 23 | } 24 | 25 | public ANTLRFileStream(String fileName, String encoding) throws IOException { 26 | this.fileName = fileName; 27 | load(fileName, encoding); 28 | } 29 | 30 | public void load(String fileName, String encoding) 31 | throws IOException 32 | { 33 | data = Utils.readFile(fileName, encoding); 34 | this.n = data.length; 35 | } 36 | 37 | @Override 38 | public String getSourceName() { 39 | return fileName; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/BaseErrorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | import org.antlr.v4.runtime.atn.ATNConfigSet; 9 | import org.antlr.v4.runtime.dfa.DFA; 10 | 11 | import java.util.BitSet; 12 | 13 | /** 14 | * Provides an empty default implementation of {@link ANTLRErrorListener}. The 15 | * default implementation of each method does nothing, but can be overridden as 16 | * necessary. 17 | * 18 | * @author Sam Harwell 19 | */ 20 | public class BaseErrorListener implements ANTLRErrorListener { 21 | @Override 22 | public void syntaxError(Recognizer recognizer, 23 | Object offendingSymbol, 24 | int line, 25 | int charPositionInLine, 26 | String msg, 27 | RecognitionException e) 28 | { 29 | } 30 | 31 | @Override 32 | public void reportAmbiguity(Parser recognizer, 33 | DFA dfa, 34 | int startIndex, 35 | int stopIndex, 36 | boolean exact, 37 | BitSet ambigAlts, 38 | ATNConfigSet configs) 39 | { 40 | } 41 | 42 | @Override 43 | public void reportAttemptingFullContext(Parser recognizer, 44 | DFA dfa, 45 | int startIndex, 46 | int stopIndex, 47 | BitSet conflictingAlts, 48 | ATNConfigSet configs) 49 | { 50 | } 51 | 52 | @Override 53 | public void reportContextSensitivity(Parser recognizer, 54 | DFA dfa, 55 | int startIndex, 56 | int stopIndex, 57 | int prediction, 58 | ATNConfigSet configs) 59 | { 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/CharStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime; 8 | 9 | import org.antlr.v4.runtime.misc.Interval; 10 | 11 | /** A source of characters for an ANTLR lexer. */ 12 | public interface CharStream extends IntStream { 13 | /** 14 | * This method returns the text for a range of characters within this input 15 | * stream. This method is guaranteed to not throw an exception if the 16 | * specified {@code interval} lies entirely within a marked range. For more 17 | * information about marked ranges, see {@link IntStream#mark}. 18 | * 19 | * @param interval an interval within the stream 20 | * @return the text of the specified interval 21 | * 22 | * @throws NullPointerException if {@code interval} is {@code null} 23 | * @throws IllegalArgumentException if {@code interval.a < 0}, or if 24 | * {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or 25 | * past the end of the stream 26 | * @throws UnsupportedOperationException if the stream does not support 27 | * getting the text of the specified interval 28 | */ 29 | public String getText(Interval interval); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/ConsoleErrorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | /** 9 | * 10 | * @author Sam Harwell 11 | */ 12 | public class ConsoleErrorListener extends BaseErrorListener { 13 | /** 14 | * Provides a default instance of {@link ConsoleErrorListener}. 15 | */ 16 | public static final ConsoleErrorListener INSTANCE = new ConsoleErrorListener(); 17 | 18 | /** 19 | * {@inheritDoc} 20 | * 21 | *

22 | * This implementation prints messages to {@link System#err} containing the 23 | * values of {@code line}, {@code charPositionInLine}, and {@code msg} using 24 | * the following format.

25 | * 26 | *
27 | 	 * line line:charPositionInLine msg
28 | 	 * 
29 | */ 30 | @Override 31 | public void syntaxError(Recognizer recognizer, 32 | Object offendingSymbol, 33 | int line, 34 | int charPositionInLine, 35 | String msg, 36 | RecognitionException e) 37 | { 38 | System.err.println("line " + line + ":" + charPositionInLine + " " + msg); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/InputMismatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | /** This signifies any kind of mismatched input exceptions such as 9 | * when the current input does not match the expected token. 10 | */ 11 | public class InputMismatchException extends RecognitionException { 12 | public InputMismatchException(Parser recognizer) { 13 | super(recognizer, recognizer.getInputStream(), recognizer._ctx); 14 | this.setOffendingToken(recognizer.getCurrentToken()); 15 | } 16 | 17 | public InputMismatchException(Parser recognizer, int state, ParserRuleContext ctx) { 18 | super(recognizer, recognizer.getInputStream(), ctx); 19 | this.setOffendingState(state); 20 | this.setOffendingToken(recognizer.getCurrentToken()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/InterpreterRuleContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | /** 9 | * This class extends {@link ParserRuleContext} by allowing the value of 10 | * {@link #getRuleIndex} to be explicitly set for the context. 11 | * 12 | *

13 | * {@link ParserRuleContext} does not include field storage for the rule index 14 | * since the context classes created by the code generator override the 15 | * {@link #getRuleIndex} method to return the correct value for that context. 16 | * Since the parser interpreter does not use the context classes generated for a 17 | * parser, this class (with slightly more memory overhead per node) is used to 18 | * provide equivalent functionality.

19 | */ 20 | public class InterpreterRuleContext extends ParserRuleContext { 21 | /** This is the backing field for {@link #getRuleIndex}. */ 22 | protected int ruleIndex = -1; 23 | 24 | public InterpreterRuleContext() { } 25 | 26 | /** 27 | * Constructs a new {@link InterpreterRuleContext} with the specified 28 | * parent, invoking state, and rule index. 29 | * 30 | * @param parent The parent context. 31 | * @param invokingStateNumber The invoking state number. 32 | * @param ruleIndex The rule index for the current context. 33 | */ 34 | public InterpreterRuleContext(ParserRuleContext parent, 35 | int invokingStateNumber, 36 | int ruleIndex) 37 | { 38 | super(parent, invokingStateNumber); 39 | this.ruleIndex = ruleIndex; 40 | } 41 | 42 | @Override 43 | public int getRuleIndex() { 44 | return ruleIndex; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/LexerNoViableAltException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime; 8 | 9 | import org.antlr.v4.runtime.atn.ATNConfigSet; 10 | import org.antlr.v4.runtime.misc.Interval; 11 | import org.antlr.v4.runtime.misc.Utils; 12 | 13 | import java.util.Locale; 14 | 15 | public class LexerNoViableAltException extends RecognitionException { 16 | /** Matching attempted at what input index? */ 17 | private final int startIndex; 18 | 19 | /** Which configurations did we try at input.index() that couldn't match input.LA(1)? */ 20 | private final ATNConfigSet deadEndConfigs; 21 | 22 | public LexerNoViableAltException(Lexer lexer, 23 | CharStream input, 24 | int startIndex, 25 | ATNConfigSet deadEndConfigs) { 26 | super(lexer, input, null); 27 | this.startIndex = startIndex; 28 | this.deadEndConfigs = deadEndConfigs; 29 | } 30 | 31 | public int getStartIndex() { 32 | return startIndex; 33 | } 34 | 35 | 36 | public ATNConfigSet getDeadEndConfigs() { 37 | return deadEndConfigs; 38 | } 39 | 40 | @Override 41 | public CharStream getInputStream() { 42 | return (CharStream)super.getInputStream(); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | String symbol = ""; 48 | if (startIndex >= 0 && startIndex < getInputStream().size()) { 49 | symbol = getInputStream().getText(Interval.of(startIndex,startIndex)); 50 | symbol = Utils.escapeWhitespace(symbol, false); 51 | } 52 | 53 | return String.format(Locale.getDefault(), "%s('%s')", LexerNoViableAltException.class.getSimpleName(), symbol); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/NoViableAltException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | import org.antlr.v4.runtime.atn.ATNConfigSet; 9 | 10 | /** Indicates that the parser could not decide which of two or more paths 11 | * to take based upon the remaining input. It tracks the starting token 12 | * of the offending input and also knows where the parser was 13 | * in the various paths when the error. Reported by reportNoViableAlternative() 14 | */ 15 | public class NoViableAltException extends RecognitionException { 16 | /** Which configurations did we try at input.index() that couldn't match input.LT(1)? */ 17 | 18 | private final ATNConfigSet deadEndConfigs; 19 | 20 | /** The token object at the start index; the input stream might 21 | * not be buffering tokens so get a reference to it. (At the 22 | * time the error occurred, of course the stream needs to keep a 23 | * buffer all of the tokens but later we might not have access to those.) 24 | */ 25 | 26 | private final Token startToken; 27 | 28 | public NoViableAltException(Parser recognizer) { // LL(1) error 29 | this(recognizer, 30 | recognizer.getInputStream(), 31 | recognizer.getCurrentToken(), 32 | recognizer.getCurrentToken(), 33 | null, 34 | recognizer._ctx); 35 | } 36 | 37 | public NoViableAltException(Parser recognizer, 38 | TokenStream input, 39 | Token startToken, 40 | Token offendingToken, 41 | ATNConfigSet deadEndConfigs, 42 | ParserRuleContext ctx) 43 | { 44 | super(recognizer, input, ctx); 45 | this.deadEndConfigs = deadEndConfigs; 46 | this.startToken = startToken; 47 | this.setOffendingToken(offendingToken); 48 | } 49 | 50 | 51 | public Token getStartToken() { 52 | return startToken; 53 | } 54 | 55 | 56 | public ATNConfigSet getDeadEndConfigs() { 57 | return deadEndConfigs; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/RuleContextWithAltNum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime; 8 | 9 | import org.antlr.v4.runtime.atn.ATN; 10 | 11 | /** A handy class for use with 12 | * 13 | * options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} 14 | * 15 | * that provides a backing field / impl for the outer alternative number 16 | * matched for an internal parse tree node. 17 | * 18 | * I'm only putting into Java runtime as I'm certain I'm the only one that 19 | * will really every use this. 20 | */ 21 | public class RuleContextWithAltNum extends ParserRuleContext { 22 | public int altNum; 23 | public RuleContextWithAltNum() { altNum = ATN.INVALID_ALT_NUMBER; } 24 | 25 | public RuleContextWithAltNum(ParserRuleContext parent, int invokingStateNumber) { 26 | super(parent, invokingStateNumber); 27 | } 28 | @Override public int getAltNumber() { return altNum; } 29 | @Override public void setAltNumber(int altNum) { this.altNum = altNum; } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/Scanner.java: -------------------------------------------------------------------------------- 1 | package org.antlr.v4.runtime; 2 | 3 | public interface Scanner { 4 | /** 5 | * Return a {@link Token} object from your input stream (usually a 6 | * {@link CharStream}). Do not fail/return upon lexing error; keep chewing 7 | * on the characters until you get a good one; errors are not passed through 8 | * to the parser. 9 | */ 10 | public Token nextToken(); 11 | 12 | /** 13 | * Set the {@link TokenFactory} this token source should use for creating 14 | * {@link Token} objects from the input. 15 | * 16 | * @param factory The {@link TokenFactory} to use for creating tokens. 17 | */ 18 | public void setTokenFactory(TokenFactory factory); 19 | 20 | /** 21 | * Gets the {@link TokenFactory} this token source is currently using for 22 | * creating {@link Token} objects from the input. 23 | * 24 | * @return The {@link TokenFactory} currently used by this token source. 25 | */ 26 | public TokenFactory getTokenFactory(); 27 | 28 | /** 29 | * Gets the name of the underlying input source. This method returns a 30 | * non-null, non-empty string. If such a name is not known, this method 31 | * returns {@link IntStream#UNKNOWN_SOURCE_NAME}. 32 | */ 33 | public String getSourceName(); 34 | 35 | /** 36 | * Get the line number for the current position in the input stream. The 37 | * first line in the input is line 1. 38 | * 39 | * @return The line number for the current position in the input stream, or 40 | * 0 if the current token source does not track line numbers. 41 | */ 42 | public int getLine(); 43 | 44 | /** 45 | * Get the index into the current line for the current position in the input 46 | * stream. The first character on a line has position 0. 47 | * 48 | * @return The line number for the current position in the input stream, or 49 | * -1 if the current token source does not track character positions. 50 | */ 51 | public int getCharPositionInLine(); 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/TokenFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime; 8 | 9 | import org.antlr.v4.runtime.misc.Pair; 10 | 11 | /** The default mechanism for creating tokens. It's used by default in Lexer and 12 | * the error handling strategy (to create missing tokens). Notifying the parser 13 | * of a new factory means that it notifies its token source and error strategy. 14 | */ 15 | public interface TokenFactory { 16 | /** This is the method used to create tokens in the lexer and in the 17 | * error handling strategy. If text!=null, than the start and stop positions 18 | * are wiped to -1 in the text override is set in the CommonToken. 19 | */ 20 | Symbol create(Pair source, int type, String text, 21 | int channel, int start, int stop, 22 | int line, int charPositionInLine); 23 | 24 | /** Generically useful */ 25 | Symbol create(int type, String text); 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/TokenSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime; 7 | 8 | /** 9 | * A source of tokens must provide a sequence of tokens via {@link #nextToken()} 10 | * and also must reveal it's source of characters; {@link CommonToken}'s text is 11 | * computed from a {@link CharStream}; it only store indices into the char 12 | * stream. 13 | * 14 | *

Errors from the lexer are never passed to the parser. Either you want to keep 15 | * going or you do not upon token recognition error. If you do not want to 16 | * continue lexing then you do not want to continue parsing. Just throw an 17 | * exception not under {@link RecognitionException} and Java will naturally toss 18 | * you all the way out of the recognizers. If you want to continue lexing then 19 | * you should not throw an exception to the parser--it has already requested a 20 | * token. Keep lexing until you get a valid one. Just report errors and keep 21 | * going, looking for a valid token.

22 | */ 23 | public interface TokenSource extends Scanner{ 24 | 25 | /** 26 | * Get the {@link CharStream} from which this token source is currently 27 | * providing tokens. 28 | * 29 | * @return The {@link CharStream} associated with the current position in 30 | * the input, or {@code null} if no input stream is available for the token 31 | * source. 32 | */ 33 | public CharStream getInputStream(); 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/WritableToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime; 8 | 9 | public interface WritableToken extends Token { 10 | public void setText(String text); 11 | 12 | public void setType(int ttype); 13 | 14 | public void setLine(int line); 15 | 16 | public void setCharPositionInLine(int pos); 17 | 18 | public void setChannel(int channel); 19 | 20 | public void setTokenIndex(int index); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public class ATNDeserializationOptions { 14 | private static final ATNDeserializationOptions defaultOptions; 15 | static { 16 | defaultOptions = new ATNDeserializationOptions(); 17 | defaultOptions.makeReadOnly(); 18 | } 19 | 20 | private boolean readOnly; 21 | private boolean verifyATN; 22 | private boolean generateRuleBypassTransitions; 23 | 24 | public ATNDeserializationOptions() { 25 | this.verifyATN = true; 26 | this.generateRuleBypassTransitions = false; 27 | } 28 | 29 | public ATNDeserializationOptions(ATNDeserializationOptions options) { 30 | this.verifyATN = options.verifyATN; 31 | this.generateRuleBypassTransitions = options.generateRuleBypassTransitions; 32 | } 33 | 34 | 35 | public static ATNDeserializationOptions getDefaultOptions() { 36 | return defaultOptions; 37 | } 38 | 39 | public final boolean isReadOnly() { 40 | return readOnly; 41 | } 42 | 43 | public final void makeReadOnly() { 44 | readOnly = true; 45 | } 46 | 47 | public final boolean isVerifyATN() { 48 | return verifyATN; 49 | } 50 | 51 | public final void setVerifyATN(boolean verifyATN) { 52 | throwIfReadOnly(); 53 | this.verifyATN = verifyATN; 54 | } 55 | 56 | public final boolean isGenerateRuleBypassTransitions() { 57 | return generateRuleBypassTransitions; 58 | } 59 | 60 | public final void setGenerateRuleBypassTransitions(boolean generateRuleBypassTransitions) { 61 | throwIfReadOnly(); 62 | this.generateRuleBypassTransitions = generateRuleBypassTransitions; 63 | } 64 | 65 | protected void throwIfReadOnly() { 66 | if (isReadOnly()) { 67 | throw new IllegalStateException("The object is read only."); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/ATNType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * Represents the type of recognizer an ATN applies to. 11 | * 12 | * @author Sam Harwell 13 | */ 14 | public enum ATNType { 15 | 16 | /** 17 | * A lexer grammar. 18 | */ 19 | LEXER, 20 | 21 | /** 22 | * A parser grammar. 23 | */ 24 | PARSER, 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/AbstractPredicateTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public abstract class AbstractPredicateTransition extends Transition { 14 | 15 | public AbstractPredicateTransition(ATNState target) { 16 | super(target); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/ActionTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public final class ActionTransition extends Transition { 10 | public final int ruleIndex; 11 | public final int actionIndex; 12 | public final boolean isCtxDependent; // e.g., $i ref in action 13 | 14 | public ActionTransition(ATNState target, int ruleIndex) { 15 | this(target, ruleIndex, -1, false); 16 | } 17 | 18 | public ActionTransition(ATNState target, int ruleIndex, int actionIndex, boolean isCtxDependent) { 19 | super(target); 20 | this.ruleIndex = ruleIndex; 21 | this.actionIndex = actionIndex; 22 | this.isCtxDependent = isCtxDependent; 23 | } 24 | 25 | @Override 26 | public int getSerializationType() { 27 | return ACTION; 28 | } 29 | 30 | @Override 31 | public boolean isEpsilon() { 32 | return true; // we are to be ignored by analysis 'cept for predicates 33 | } 34 | 35 | @Override 36 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 37 | return false; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "action_"+ruleIndex+":"+actionIndex; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/AtomTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.misc.IntervalSet; 10 | 11 | /** TODO: make all transitions sets? no, should remove set edges */ 12 | public final class AtomTransition extends Transition { 13 | /** The token type or character value; or, signifies special label. */ 14 | public final int label; 15 | 16 | public AtomTransition(ATNState target, int label) { 17 | super(target); 18 | this.label = label; 19 | } 20 | 21 | @Override 22 | public int getSerializationType() { 23 | return ATOM; 24 | } 25 | 26 | @Override 27 | 28 | public IntervalSet label() { return IntervalSet.of(label); } 29 | 30 | @Override 31 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 32 | return label == symbol; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return String.valueOf(label); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/BasicBlockStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public final class BasicBlockStartState extends BlockStartState { 14 | @Override 15 | public int getStateType() { 16 | return BLOCK_START; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/BasicState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public final class BasicState extends ATNState { 14 | 15 | @Override 16 | public int getStateType() { 17 | return BASIC; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/BlockEndState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** Terminal node of a simple {@code (a|b|c)} block. */ 10 | public final class BlockEndState extends ATNState { 11 | public BlockStartState startState; 12 | 13 | @Override 14 | public int getStateType() { 15 | return BLOCK_END; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/BlockStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** The start of a regular {@code (...)} block. */ 10 | public abstract class BlockStartState extends DecisionState { 11 | public BlockEndState endState; 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/CodePointTransitions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.misc.IntervalSet; 10 | 11 | /** 12 | * Utility class to create {@link AtomTransition}, {@link RangeTransition}, 13 | * and {@link SetTransition} appropriately based on the range of the input. 14 | * 15 | * To keep the serialized ATN size small, we only inline atom and 16 | * range transitions for Unicode code points <= U+FFFF. 17 | * 18 | * Whenever we encounter a Unicode code point > U+FFFF, we represent that 19 | * as a set transition (even if it is logically an atom or a range). 20 | */ 21 | public abstract class CodePointTransitions { 22 | /** 23 | * If {@code codePoint} is <= U+FFFF, returns a new {@link AtomTransition}. 24 | * Otherwise, returns a new {@link SetTransition}. 25 | */ 26 | public static Transition createWithCodePoint(ATNState target, int codePoint) { 27 | if (Character.isSupplementaryCodePoint(codePoint)) { 28 | return new SetTransition(target, IntervalSet.of(codePoint)); 29 | } 30 | else { 31 | return new AtomTransition(target, codePoint); 32 | } 33 | } 34 | 35 | /** 36 | * If {@code codePointFrom} and {@code codePointTo} are both 37 | * <= U+FFFF, returns a new {@link RangeTransition}. 38 | * Otherwise, returns a new {@link SetTransition}. 39 | */ 40 | public static Transition createWithCodePointRange( 41 | ATNState target, 42 | int codePointFrom, 43 | int codePointTo) { 44 | if (Character.isSupplementaryCodePoint(codePointFrom) || 45 | Character.isSupplementaryCodePoint(codePointTo)) { 46 | return new SetTransition(target, IntervalSet.of(codePointFrom, codePointTo)); 47 | } 48 | else { 49 | return new RangeTransition(target, codePointFrom, codePointTo); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/ContextSensitivityInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.ANTLRErrorListener; 10 | import org.antlr.v4.runtime.TokenStream; 11 | 12 | /** 13 | * This class represents profiling event information for a context sensitivity. 14 | * Context sensitivities are decisions where a particular input resulted in an 15 | * SLL conflict, but LL prediction produced a single unique alternative. 16 | * 17 | *

18 | * In some cases, the unique alternative identified by LL prediction is not 19 | * equal to the minimum represented alternative in the conflicting SLL 20 | * configuration set. Grammars and inputs which result in this scenario are 21 | * unable to use {@link PredictionMode#SLL}, which in turn means they cannot use 22 | * the two-stage parsing strategy to improve parsing performance for that 23 | * input.

24 | * 25 | * @see ParserATNSimulator#reportContextSensitivity 26 | * @see ANTLRErrorListener#reportContextSensitivity 27 | * 28 | * @since 4.3 29 | */ 30 | public class ContextSensitivityInfo extends DecisionEventInfo { 31 | /** 32 | * Constructs a new instance of the {@link ContextSensitivityInfo} class 33 | * with the specified detailed context sensitivity information. 34 | * 35 | * @param decision The decision number 36 | * @param configs The final configuration set containing the unique 37 | * alternative identified by full-context prediction 38 | * @param input The input token stream 39 | * @param startIndex The start index for the current prediction 40 | * @param stopIndex The index at which the context sensitivity was 41 | * identified during full-context prediction 42 | */ 43 | public ContextSensitivityInfo(int decision, 44 | ATNConfigSet configs, 45 | TokenStream input, int startIndex, int stopIndex) 46 | { 47 | super( decision, configs, input, startIndex, stopIndex, true); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/DecisionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public abstract class DecisionState extends ATNState { 10 | public int decision = -1; 11 | public boolean nonGreedy; 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/EmptyPredictionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public class EmptyPredictionContext extends SingletonPredictionContext { 10 | public EmptyPredictionContext() { 11 | super(null, EMPTY_RETURN_STATE); 12 | } 13 | 14 | @Override 15 | public boolean isEmpty() { return true; } 16 | 17 | @Override 18 | public int size() { 19 | return 1; 20 | } 21 | 22 | @Override 23 | public PredictionContext getParent(int index) { 24 | return null; 25 | } 26 | 27 | @Override 28 | public int getReturnState(int index) { 29 | return returnState; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object o) { 34 | return this == o; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "$"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/EpsilonTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public final class EpsilonTransition extends Transition { 10 | 11 | private final int outermostPrecedenceReturn; 12 | 13 | public EpsilonTransition(ATNState target) { 14 | this(target, -1); 15 | } 16 | 17 | public EpsilonTransition(ATNState target, int outermostPrecedenceReturn) { 18 | super(target); 19 | this.outermostPrecedenceReturn = outermostPrecedenceReturn; 20 | } 21 | 22 | /** 23 | * @return the rule index of a precedence rule for which this transition is 24 | * returning from, where the precedence value is 0; otherwise, -1. 25 | * 26 | * @see ATNConfig#isPrecedenceFilterSuppressed() 27 | * @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet) 28 | * @since 4.4.1 29 | */ 30 | public int outermostPrecedenceReturn() { 31 | return outermostPrecedenceReturn; 32 | } 33 | 34 | @Override 35 | public int getSerializationType() { 36 | return EPSILON; 37 | } 38 | 39 | @Override 40 | public boolean isEpsilon() { return true; } 41 | 42 | @Override 43 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 44 | return false; 45 | } 46 | 47 | @Override 48 | 49 | public String toString() { 50 | return "epsilon"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/ErrorInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.ANTLRErrorListener; 10 | import org.antlr.v4.runtime.Parser; 11 | import org.antlr.v4.runtime.RecognitionException; 12 | import org.antlr.v4.runtime.Token; 13 | import org.antlr.v4.runtime.TokenStream; 14 | 15 | /** 16 | * This class represents profiling event information for a syntax error 17 | * identified during prediction. Syntax errors occur when the prediction 18 | * algorithm is unable to identify an alternative which would lead to a 19 | * successful parse. 20 | * 21 | * @see Parser#notifyErrorListeners(Token, String, RecognitionException) 22 | * @see ANTLRErrorListener#syntaxError 23 | * 24 | * @since 4.3 25 | */ 26 | public class ErrorInfo extends DecisionEventInfo { 27 | /** 28 | * Constructs a new instance of the {@link ErrorInfo} class with the 29 | * specified detailed syntax error information. 30 | * 31 | * @param decision The decision number 32 | * @param configs The final configuration set reached during prediction 33 | * prior to reaching the {@link ATNSimulator#ERROR} state 34 | * @param input The input token stream 35 | * @param startIndex The start index for the current prediction 36 | * @param stopIndex The index at which the syntax error was identified 37 | * @param fullCtx {@code true} if the syntax error was identified during LL 38 | * prediction; otherwise, {@code false} if the syntax error was identified 39 | * during SLL prediction 40 | */ 41 | public ErrorInfo(int decision, 42 | ATNConfigSet configs, 43 | TokenStream input, int startIndex, int stopIndex, 44 | boolean fullCtx) 45 | { 46 | super(decision, configs, input, startIndex, stopIndex, fullCtx); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LexerAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.CharStream; 10 | import org.antlr.v4.runtime.Lexer; 11 | 12 | /** 13 | * Represents a single action which can be executed following the successful 14 | * match of a lexer rule. Lexer actions are used for both embedded action syntax 15 | * and ANTLR 4's new lexer command syntax. 16 | * 17 | * @author Sam Harwell 18 | * @since 4.2 19 | */ 20 | public interface LexerAction { 21 | /** 22 | * Gets the serialization type of the lexer action. 23 | * 24 | * @return The serialization type of the lexer action. 25 | */ 26 | LexerActionType getActionType(); 27 | 28 | /** 29 | * Gets whether the lexer action is position-dependent. Position-dependent 30 | * actions may have different semantics depending on the {@link CharStream} 31 | * index at the time the action is executed. 32 | * 33 | *

Many lexer commands, including {@code type}, {@code skip}, and 34 | * {@code more}, do not check the input index during their execution. 35 | * Actions like this are position-independent, and may be stored more 36 | * efficiently as part of the {@link LexerATNConfig#lexerActionExecutor}.

37 | * 38 | * @return {@code true} if the lexer action semantics can be affected by the 39 | * position of the input {@link CharStream} at the time it is executed; 40 | * otherwise, {@code false}. 41 | */ 42 | boolean isPositionDependent(); 43 | 44 | /** 45 | * Execute the lexer action in the context of the specified {@link Lexer}. 46 | * 47 | *

For position-dependent actions, the input stream must already be 48 | * positioned correctly prior to calling this method.

49 | * 50 | * @param lexer The lexer instance. 51 | */ 52 | void execute(Lexer lexer); 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LexerActionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * Represents the serialization type of a {@link LexerAction}. 11 | * 12 | * @author Sam Harwell 13 | * @since 4.2 14 | */ 15 | public enum LexerActionType { 16 | /** 17 | * The type of a {@link LexerChannelAction} action. 18 | */ 19 | CHANNEL, 20 | /** 21 | * The type of a {@link LexerCustomAction} action. 22 | */ 23 | CUSTOM, 24 | /** 25 | * The type of a {@link LexerModeAction} action. 26 | */ 27 | MODE, 28 | /** 29 | * The type of a {@link LexerMoreAction} action. 30 | */ 31 | MORE, 32 | /** 33 | * The type of a {@link LexerPopModeAction} action. 34 | */ 35 | POP_MODE, 36 | /** 37 | * The type of a {@link LexerPushModeAction} action. 38 | */ 39 | PUSH_MODE, 40 | /** 41 | * The type of a {@link LexerSkipAction} action. 42 | */ 43 | SKIP, 44 | /** 45 | * The type of a {@link LexerTypeAction} action. 46 | */ 47 | TYPE, 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LexerMoreAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.Lexer; 10 | import org.antlr.v4.runtime.misc.MurmurHash; 11 | 12 | /** 13 | * Implements the {@code more} lexer action by calling {@link Lexer#more}. 14 | * 15 | *

The {@code more} command does not have any parameters, so this action is 16 | * implemented as a singleton instance exposed by {@link #INSTANCE}.

17 | * 18 | * @author Sam Harwell 19 | * @since 4.2 20 | */ 21 | public final class LexerMoreAction implements LexerAction { 22 | /** 23 | * Provides a singleton instance of this parameterless lexer action. 24 | */ 25 | public static final LexerMoreAction INSTANCE = new LexerMoreAction(); 26 | 27 | /** 28 | * Constructs the singleton instance of the lexer {@code more} command. 29 | */ 30 | private LexerMoreAction() { 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | * @return This method returns {@link LexerActionType#MORE}. 36 | */ 37 | @Override 38 | public LexerActionType getActionType() { 39 | return LexerActionType.MORE; 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | * @return This method returns {@code false}. 45 | */ 46 | @Override 47 | public boolean isPositionDependent() { 48 | return false; 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | * 54 | *

This action is implemented by calling {@link Lexer#more}.

55 | */ 56 | @Override 57 | public void execute(Lexer lexer) { 58 | lexer.more(); 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | int hash = MurmurHash.initialize(); 64 | hash = MurmurHash.update(hash, getActionType().ordinal()); 65 | return MurmurHash.finish(hash, 1); 66 | } 67 | 68 | @Override 69 | @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") 70 | public boolean equals(Object obj) { 71 | return obj == this; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "more"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LexerPopModeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.Lexer; 10 | import org.antlr.v4.runtime.misc.MurmurHash; 11 | 12 | /** 13 | * Implements the {@code popMode} lexer action by calling {@link Lexer#popMode}. 14 | * 15 | *

The {@code popMode} command does not have any parameters, so this action is 16 | * implemented as a singleton instance exposed by {@link #INSTANCE}.

17 | * 18 | * @author Sam Harwell 19 | * @since 4.2 20 | */ 21 | public final class LexerPopModeAction implements LexerAction { 22 | /** 23 | * Provides a singleton instance of this parameterless lexer action. 24 | */ 25 | public static final LexerPopModeAction INSTANCE = new LexerPopModeAction(); 26 | 27 | /** 28 | * Constructs the singleton instance of the lexer {@code popMode} command. 29 | */ 30 | private LexerPopModeAction() { 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | * @return This method returns {@link LexerActionType#POP_MODE}. 36 | */ 37 | @Override 38 | public LexerActionType getActionType() { 39 | return LexerActionType.POP_MODE; 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | * @return This method returns {@code false}. 45 | */ 46 | @Override 47 | public boolean isPositionDependent() { 48 | return false; 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | * 54 | *

This action is implemented by calling {@link Lexer#popMode}.

55 | */ 56 | @Override 57 | public void execute(Lexer lexer) { 58 | lexer.popMode(); 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | int hash = MurmurHash.initialize(); 64 | hash = MurmurHash.update(hash, getActionType().ordinal()); 65 | return MurmurHash.finish(hash, 1); 66 | } 67 | 68 | @Override 69 | @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") 70 | public boolean equals(Object obj) { 71 | return obj == this; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "popMode"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LexerSkipAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.Lexer; 10 | import org.antlr.v4.runtime.misc.MurmurHash; 11 | 12 | /** 13 | * Implements the {@code skip} lexer action by calling {@link Lexer#skip}. 14 | * 15 | *

The {@code skip} command does not have any parameters, so this action is 16 | * implemented as a singleton instance exposed by {@link #INSTANCE}.

17 | * 18 | * @author Sam Harwell 19 | * @since 4.2 20 | */ 21 | public final class LexerSkipAction implements LexerAction { 22 | /** 23 | * Provides a singleton instance of this parameterless lexer action. 24 | */ 25 | public static final LexerSkipAction INSTANCE = new LexerSkipAction(); 26 | 27 | /** 28 | * Constructs the singleton instance of the lexer {@code skip} command. 29 | */ 30 | private LexerSkipAction() { 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | * @return This method returns {@link LexerActionType#SKIP}. 36 | */ 37 | @Override 38 | public LexerActionType getActionType() { 39 | return LexerActionType.SKIP; 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | * @return This method returns {@code false}. 45 | */ 46 | @Override 47 | public boolean isPositionDependent() { 48 | return false; 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | * 54 | *

This action is implemented by calling {@link Lexer#skip}.

55 | */ 56 | @Override 57 | public void execute(Lexer lexer) { 58 | lexer.skip(); 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | int hash = MurmurHash.initialize(); 64 | hash = MurmurHash.update(hash, getActionType().ordinal()); 65 | return MurmurHash.finish(hash, 1); 66 | } 67 | 68 | @Override 69 | @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") 70 | public boolean equals(Object obj) { 71 | return obj == this; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "skip"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LookaheadEventInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.TokenStream; 10 | 11 | /** 12 | * This class represents profiling event information for tracking the lookahead 13 | * depth required in order to make a prediction. 14 | * 15 | * @since 4.3 16 | */ 17 | public class LookaheadEventInfo extends DecisionEventInfo { 18 | /** The alternative chosen by adaptivePredict(), not necessarily 19 | * the outermost alt shown for a rule; left-recursive rules have 20 | * user-level alts that differ from the rewritten rule with a (...) block 21 | * and a (..)* loop. 22 | */ 23 | public int predictedAlt; 24 | 25 | /** 26 | * Constructs a new instance of the {@link LookaheadEventInfo} class with 27 | * the specified detailed lookahead information. 28 | * 29 | * @param decision The decision number 30 | * @param configs The final configuration set containing the necessary 31 | * information to determine the result of a prediction, or {@code null} if 32 | * the final configuration set is not available 33 | * @param input The input token stream 34 | * @param startIndex The start index for the current prediction 35 | * @param stopIndex The index at which the prediction was finally made 36 | * @param fullCtx {@code true} if the current lookahead is part of an LL 37 | * prediction; otherwise, {@code false} if the current lookahead is part of 38 | * an SLL prediction 39 | */ 40 | public LookaheadEventInfo(int decision, 41 | ATNConfigSet configs, 42 | int predictedAlt, 43 | TokenStream input, int startIndex, int stopIndex, 44 | boolean fullCtx) 45 | { 46 | super(decision, configs, input, startIndex, stopIndex, fullCtx); 47 | this.predictedAlt = predictedAlt; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/LoopEndState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** Mark the end of a * or + loop. */ 10 | public final class LoopEndState extends ATNState { 11 | public ATNState loopBackState; 12 | 13 | @Override 14 | public int getStateType() { 15 | return LOOP_END; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/NotSetTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.misc.IntervalSet; 10 | 11 | public final class NotSetTransition extends SetTransition { 12 | public NotSetTransition(ATNState target, IntervalSet set) { 13 | super(target, set); 14 | } 15 | 16 | @Override 17 | public int getSerializationType() { 18 | return NOT_SET; 19 | } 20 | 21 | @Override 22 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 23 | return symbol >= minVocabSymbol 24 | && symbol <= maxVocabSymbol 25 | && !super.matches(symbol, minVocabSymbol, maxVocabSymbol); 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return '~'+super.toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/OrderedATNConfigSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.misc.ObjectEqualityComparator; 10 | 11 | /** 12 | * 13 | * @author Sam Harwell 14 | */ 15 | public class OrderedATNConfigSet extends ATNConfigSet { 16 | 17 | public OrderedATNConfigSet() { 18 | this.configLookup = new LexerConfigHashSet(); 19 | } 20 | 21 | public static class LexerConfigHashSet extends AbstractConfigHashSet { 22 | public LexerConfigHashSet() { 23 | super(ObjectEqualityComparator.INSTANCE); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/PlusBlockStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** Start of {@code (A|B|...)+} loop. Technically a decision state, but 10 | * we don't use for code generation; somebody might need it, so I'm defining 11 | * it for completeness. In reality, the {@link PlusLoopbackState} node is the 12 | * real decision-making note for {@code A+}. 13 | */ 14 | public final class PlusBlockStartState extends BlockStartState { 15 | public PlusLoopbackState loopBackState; 16 | 17 | @Override 18 | public int getStateType() { 19 | return PLUS_BLOCK_START; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/PlusLoopbackState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: 10 | * one to the loop back to start of the block and one to exit. 11 | */ 12 | public final class PlusLoopbackState extends DecisionState { 13 | 14 | @Override 15 | public int getStateType() { 16 | return PLUS_LOOP_BACK; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/PrecedencePredicateTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** 10 | * 11 | * @author Sam Harwell 12 | */ 13 | public final class PrecedencePredicateTransition extends AbstractPredicateTransition { 14 | public final int precedence; 15 | 16 | public PrecedencePredicateTransition(ATNState target, int precedence) { 17 | super(target); 18 | this.precedence = precedence; 19 | } 20 | 21 | @Override 22 | public int getSerializationType() { 23 | return PRECEDENCE; 24 | } 25 | 26 | @Override 27 | public boolean isEpsilon() { 28 | return true; 29 | } 30 | 31 | @Override 32 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 33 | return false; 34 | } 35 | 36 | public SemanticContext.PrecedencePredicate getPredicate() { 37 | return new SemanticContext.PrecedencePredicate(precedence); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return precedence + " >= _p"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/PredicateTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** TODO: this is old comment: 10 | * A tree of semantic predicates from the grammar AST if label==SEMPRED. 11 | * In the ATN, labels will always be exactly one predicate, but the DFA 12 | * may have to combine a bunch of them as it collects predicates from 13 | * multiple ATN configurations into a single DFA state. 14 | */ 15 | public final class PredicateTransition extends AbstractPredicateTransition { 16 | public final int ruleIndex; 17 | public final int predIndex; 18 | public final boolean isCtxDependent; // e.g., $i ref in pred 19 | 20 | public PredicateTransition(ATNState target, int ruleIndex, int predIndex, boolean isCtxDependent) { 21 | super(target); 22 | this.ruleIndex = ruleIndex; 23 | this.predIndex = predIndex; 24 | this.isCtxDependent = isCtxDependent; 25 | } 26 | 27 | @Override 28 | public int getSerializationType() { 29 | return PREDICATE; 30 | } 31 | 32 | @Override 33 | public boolean isEpsilon() { return true; } 34 | 35 | @Override 36 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 37 | return false; 38 | } 39 | 40 | public SemanticContext.Predicate getPredicate() { 41 | return new SemanticContext.Predicate(ruleIndex, predIndex, isCtxDependent); 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "pred_"+ruleIndex+":"+predIndex; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/PredictionContextCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | /** Used to cache {@link PredictionContext} objects. Its used for the shared 13 | * context cash associated with contexts in DFA states. This cache 14 | * can be used for both lexers and parsers. 15 | */ 16 | public class PredictionContextCache { 17 | protected final Map cache = 18 | new HashMap(); 19 | 20 | /** Add a context to the cache and return it. If the context already exists, 21 | * return that one instead and do not add a new context to the cache. 22 | * Protect shared cache from unsafe thread access. 23 | */ 24 | public PredictionContext add(PredictionContext ctx) { 25 | if ( ctx==PredictionContext.EMPTY ) return PredictionContext.EMPTY; 26 | PredictionContext existing = cache.get(ctx); 27 | if ( existing!=null ) { 28 | // System.out.println(name+" reuses "+existing); 29 | return existing; 30 | } 31 | cache.put(ctx, ctx); 32 | return ctx; 33 | } 34 | 35 | public PredictionContext get(PredictionContext ctx) { 36 | return cache.get(ctx); 37 | } 38 | 39 | public int size() { 40 | return cache.size(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/RangeTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.misc.IntervalSet; 10 | 11 | public final class RangeTransition extends Transition { 12 | public final int from; 13 | public final int to; 14 | 15 | public RangeTransition(ATNState target, int from, int to) { 16 | super(target); 17 | this.from = from; 18 | this.to = to; 19 | } 20 | 21 | @Override 22 | public int getSerializationType() { 23 | return RANGE; 24 | } 25 | 26 | @Override 27 | 28 | public IntervalSet label() { return IntervalSet.of(from, to); } 29 | 30 | @Override 31 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 32 | return symbol >= from && symbol <= to; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return new StringBuilder("'") 38 | .appendCodePoint(from) 39 | .append("'..'") 40 | .appendCodePoint(to) 41 | .append("'") 42 | .toString(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/RuleStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public final class RuleStartState extends ATNState { 10 | public RuleStopState stopState; 11 | public boolean isLeftRecursiveRule; 12 | 13 | @Override 14 | public int getStateType() { 15 | return RULE_START; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/RuleStopState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** The last node in the ATN for a rule, unless that rule is the start symbol. 10 | * In that case, there is one transition to EOF. Later, we might encode 11 | * references to all calls to this rule to compute FOLLOW sets for 12 | * error handling. 13 | */ 14 | public final class RuleStopState extends ATNState { 15 | 16 | @Override 17 | public int getStateType() { 18 | return RULE_STOP; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/RuleTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** */ 10 | public final class RuleTransition extends Transition { 11 | /** Ptr to the rule definition object for this rule ref */ 12 | public final int ruleIndex; // no Rule object at runtime 13 | 14 | public final int precedence; 15 | 16 | /** What node to begin computations following ref to rule */ 17 | public ATNState followState; 18 | 19 | /** 20 | * @deprecated Use 21 | * {@link #RuleTransition(RuleStartState, int, int, ATNState)} instead. 22 | */ 23 | @Deprecated 24 | public RuleTransition(RuleStartState ruleStart, 25 | int ruleIndex, 26 | ATNState followState) 27 | { 28 | this(ruleStart, ruleIndex, 0, followState); 29 | } 30 | 31 | public RuleTransition(RuleStartState ruleStart, 32 | int ruleIndex, 33 | int precedence, 34 | ATNState followState) 35 | { 36 | super(ruleStart); 37 | this.ruleIndex = ruleIndex; 38 | this.precedence = precedence; 39 | this.followState = followState; 40 | } 41 | 42 | @Override 43 | public int getSerializationType() { 44 | return RULE; 45 | } 46 | 47 | @Override 48 | public boolean isEpsilon() { return true; } 49 | 50 | @Override 51 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/SetTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.Token; 10 | import org.antlr.v4.runtime.misc.IntervalSet; 11 | 12 | /** A transition containing a set of values. */ 13 | public class SetTransition extends Transition { 14 | public final IntervalSet set; 15 | 16 | // TODO (sam): should we really allow null here? 17 | public SetTransition(ATNState target, IntervalSet set) { 18 | super(target); 19 | if ( set == null ) set = IntervalSet.of(Token.INVALID_TYPE); 20 | this.set = set; 21 | } 22 | 23 | @Override 24 | public int getSerializationType() { 25 | return SET; 26 | } 27 | 28 | @Override 29 | 30 | public IntervalSet label() { return set; } 31 | 32 | @Override 33 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 34 | return set.contains(symbol); 35 | } 36 | 37 | @Override 38 | 39 | public String toString() { 40 | return set.toString(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/StarBlockStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** The block that begins a closure loop. */ 10 | public final class StarBlockStartState extends BlockStartState { 11 | 12 | @Override 13 | public int getStateType() { 14 | return STAR_BLOCK_START; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/StarLoopEntryState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | import org.antlr.v4.runtime.ParserInterpreter; 10 | import org.antlr.v4.runtime.dfa.DFA; 11 | 12 | public final class StarLoopEntryState extends DecisionState { 13 | public StarLoopbackState loopBackState; 14 | 15 | /** 16 | * Indicates whether this state can benefit from a precedence DFA during SLL 17 | * decision making. 18 | * 19 | *

This is a computed property that is calculated during ATN deserialization 20 | * and stored for use in {@link ParserATNSimulator} and 21 | * {@link ParserInterpreter}.

22 | * 23 | * @see DFA#isPrecedenceDfa() 24 | */ 25 | public boolean isPrecedenceDecision; 26 | 27 | @Override 28 | public int getStateType() { 29 | return STAR_LOOP_ENTRY; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/StarLoopbackState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public final class StarLoopbackState extends ATNState { 10 | public final StarLoopEntryState getLoopEntryState() { 11 | return (StarLoopEntryState)transition(0).target; 12 | } 13 | 14 | @Override 15 | public int getStateType() { 16 | return STAR_LOOP_BACK; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/TokensStartState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | /** The Tokens rule start state linking to each lexer rule start state */ 10 | public final class TokensStartState extends DecisionState { 11 | 12 | @Override 13 | public int getStateType() { 14 | return TOKEN_START; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/atn/WildcardTransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.atn; 8 | 9 | public final class WildcardTransition extends Transition { 10 | public WildcardTransition(ATNState target) { super(target); } 11 | 12 | @Override 13 | public int getSerializationType() { 14 | return WILDCARD; 15 | } 16 | 17 | @Override 18 | public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) { 19 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "."; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/dfa/LexerDFASerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.dfa; 8 | 9 | import org.antlr.v4.runtime.VocabularyImpl; 10 | 11 | public class LexerDFASerializer extends DFASerializer { 12 | public LexerDFASerializer(DFA dfa) { 13 | super(dfa, VocabularyImpl.EMPTY_VOCABULARY); 14 | } 15 | 16 | @Override 17 | 18 | protected String getEdgeLabel(int i) { 19 | return new StringBuilder("'") 20 | .appendCodePoint(i) 21 | .append("'") 22 | .toString(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/AbstractEqualityComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime.misc; 7 | 8 | /** 9 | * This abstract base class is provided so performance-critical applications can 10 | * use virtual- instead of interface-dispatch when calling comparator methods. 11 | * 12 | * @author Sam Harwell 13 | */ 14 | public abstract class AbstractEqualityComparator implements EqualityComparator { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/DoubleKeyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | import java.util.Collection; 10 | import java.util.LinkedHashMap; 11 | import java.util.Map; 12 | import java.util.Set; 13 | 14 | /** Sometimes we need to map a key to a value but key is two pieces of data. 15 | * This nested hash table saves creating a single key each time we access 16 | * map; avoids mem creation. 17 | */ 18 | public class DoubleKeyMap { 19 | Map> data = new LinkedHashMap>(); 20 | 21 | public Value put(Key1 k1, Key2 k2, Value v) { 22 | Map data2 = data.get(k1); 23 | Value prev = null; 24 | if ( data2==null ) { 25 | data2 = new LinkedHashMap(); 26 | data.put(k1, data2); 27 | } 28 | else { 29 | prev = data2.get(k2); 30 | } 31 | data2.put(k2, v); 32 | return prev; 33 | } 34 | 35 | public Value get(Key1 k1, Key2 k2) { 36 | Map data2 = data.get(k1); 37 | if ( data2==null ) return null; 38 | return data2.get(k2); 39 | } 40 | 41 | public Map get(Key1 k1) { return data.get(k1); } 42 | 43 | /** Get all values associated with primary key */ 44 | public Collection values(Key1 k1) { 45 | Map data2 = data.get(k1); 46 | if ( data2==null ) return null; 47 | return data2.values(); 48 | } 49 | 50 | /** get all primary keys */ 51 | public Set keySet() { 52 | return data.keySet(); 53 | } 54 | 55 | /** get all secondary keys associated with a primary key */ 56 | public Set keySet(Key1 k1) { 57 | Map data2 = data.get(k1); 58 | if ( data2==null ) return null; 59 | return data2.keySet(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/EqualityComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime.misc; 7 | 8 | /** 9 | * This interface provides an abstract concept of object equality independent of 10 | * {@link Object#equals} (object equality) and the {@code ==} operator 11 | * (reference equality). It can be used to provide algorithm-specific unordered 12 | * comparisons without requiring changes to the object itself. 13 | * 14 | * @author Sam Harwell 15 | */ 16 | public interface EqualityComparator { 17 | 18 | /** 19 | * This method returns a hash code for the specified object. 20 | * 21 | * @param obj The object. 22 | * @return The hash code for {@code obj}. 23 | */ 24 | int hashCode(T obj); 25 | 26 | /** 27 | * This method tests if two objects are equal. 28 | * 29 | * @param a The first object to compare. 30 | * @param b The second object to compare. 31 | * @return {@code true} if {@code a} equals {@code b}, otherwise {@code false}. 32 | */ 33 | boolean equals(T a, T b); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/IntegerStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime.misc; 7 | 8 | /** 9 | * 10 | * @author Sam Harwell 11 | */ 12 | public class IntegerStack extends IntegerList { 13 | 14 | public IntegerStack() { 15 | } 16 | 17 | public IntegerStack(int capacity) { 18 | super(capacity); 19 | } 20 | 21 | public IntegerStack(IntegerStack list) { 22 | super(list); 23 | } 24 | 25 | public final void push(int value) { 26 | add(value); 27 | } 28 | 29 | public final int pop() { 30 | return removeAt(size() - 1); 31 | } 32 | 33 | public final int peek() { 34 | return get(size() - 1); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/MultiMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | import java.util.ArrayList; 10 | import java.util.LinkedHashMap; 11 | import java.util.List; 12 | 13 | public class MultiMap extends LinkedHashMap> { 14 | public void map(K key, V value) { 15 | List elementsForKey = get(key); 16 | if ( elementsForKey==null ) { 17 | elementsForKey = new ArrayList(); 18 | super.put(key, elementsForKey); 19 | } 20 | elementsForKey.add(value); 21 | } 22 | 23 | public List> getPairs() { 24 | List> pairs = new ArrayList>(); 25 | for (K key : keySet()) { 26 | for (V value : get(key)) { 27 | pairs.add(new Pair(key, value)); 28 | } 29 | } 30 | return pairs; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime.misc; 7 | 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.RetentionPolicy; 12 | import java.lang.annotation.Target; 13 | 14 | /** @deprecated THIS IS HERE FOR BACKWARD COMPATIBILITY WITH 4.5 ONLY. It will 15 | * disappear in 4.6+ 16 | */ 17 | @Documented 18 | @Retention(RetentionPolicy.CLASS) 19 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 20 | public @interface NotNull { 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/ObjectEqualityComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | package org.antlr.v4.runtime.misc; 7 | 8 | /** 9 | * This default implementation of {@link EqualityComparator} uses object equality 10 | * for comparisons by calling {@link Object#hashCode} and {@link Object#equals}. 11 | * 12 | * @author Sam Harwell 13 | */ 14 | public final class ObjectEqualityComparator extends AbstractEqualityComparator { 15 | public static final ObjectEqualityComparator INSTANCE = new ObjectEqualityComparator(); 16 | 17 | /** 18 | * {@inheritDoc} 19 | * 20 | *

This implementation returns 21 | * {@code obj.}{@link Object#hashCode hashCode()}.

22 | */ 23 | @Override 24 | public int hashCode(Object obj) { 25 | if (obj == null) { 26 | return 0; 27 | } 28 | 29 | return obj.hashCode(); 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | * 35 | *

This implementation relies on object equality. If both objects are 36 | * {@code null}, this method returns {@code true}. Otherwise if only 37 | * {@code a} is {@code null}, this method returns {@code false}. Otherwise, 38 | * this method returns the result of 39 | * {@code a.}{@link Object#equals equals}{@code (b)}.

40 | */ 41 | @Override 42 | public boolean equals(Object a, Object b) { 43 | if (a == null) { 44 | return b == null; 45 | } 46 | 47 | return a.equals(b); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | import java.io.Serializable; 10 | 11 | public class Pair implements Serializable { 12 | public final A a; 13 | public final B b; 14 | 15 | public Pair(A a, B b) { 16 | this.a = a; 17 | this.b = b; 18 | } 19 | 20 | @Override 21 | public boolean equals(Object obj) { 22 | if (obj == this) { 23 | return true; 24 | } 25 | else if (!(obj instanceof Pair)) { 26 | return false; 27 | } 28 | 29 | Pair other = (Pair)obj; 30 | return ObjectEqualityComparator.INSTANCE.equals(a, other.a) 31 | && ObjectEqualityComparator.INSTANCE.equals(b, other.b); 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | int hash = MurmurHash.initialize(); 37 | hash = MurmurHash.update(hash, a); 38 | hash = MurmurHash.update(hash, b); 39 | return MurmurHash.finish(hash, 2); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return String.format("(%s, %s)", a, b); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/ParseCancellationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | import org.antlr.v4.runtime.BailErrorStrategy; 10 | import org.antlr.v4.runtime.RecognitionException; 11 | 12 | import java.util.concurrent.CancellationException; 13 | 14 | /** 15 | * This exception is thrown to cancel a parsing operation. This exception does 16 | * not extend {@link RecognitionException}, allowing it to bypass the standard 17 | * error recovery mechanisms. {@link BailErrorStrategy} throws this exception in 18 | * response to a parse error. 19 | * 20 | * @author Sam Harwell 21 | */ 22 | public class ParseCancellationException extends CancellationException { 23 | 24 | public ParseCancellationException() { 25 | } 26 | 27 | public ParseCancellationException(String message) { 28 | super(message); 29 | } 30 | 31 | public ParseCancellationException(Throwable cause) { 32 | initCause(cause); 33 | } 34 | 35 | public ParseCancellationException(String message, Throwable cause) { 36 | super(message); 37 | initCause(cause); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/Predicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | public interface Predicate { 10 | boolean test(T t); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/TestRig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | import java.lang.reflect.Method; 10 | 11 | /** A proxy for the real org.antlr.v4.gui.TestRig that we moved to tool 12 | * artifact from runtime. 13 | * 14 | * @deprecated 15 | * @since 4.5.1 16 | */ 17 | public class TestRig { 18 | public static void main(String[] args) { 19 | try { 20 | Class testRigClass = Class.forName("org.antlr.v4.gui.TestRig"); 21 | System.err.println("Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically"); 22 | try { 23 | Method mainMethod = testRigClass.getMethod("main", String[].class); 24 | mainMethod.invoke(null, (Object)args); 25 | } 26 | catch (Exception nsme) { 27 | System.err.println("Problems calling org.antlr.v4.gui.TestRig.main(args)"); 28 | } 29 | } 30 | catch (ClassNotFoundException cnfe) { 31 | System.err.println("Use of TestRig now requires the use of the tool jar, antlr-4.X-complete.jar"); 32 | System.err.println("Maven users need group ID org.antlr and artifact ID antlr4"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/misc/Triple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.misc; 8 | 9 | public class Triple { 10 | public final A a; 11 | public final B b; 12 | public final C c; 13 | 14 | public Triple(A a, B b, C c) { 15 | this.a = a; 16 | this.b = b; 17 | this.c = c; 18 | } 19 | 20 | @Override 21 | public boolean equals(Object obj) { 22 | if (obj == this) { 23 | return true; 24 | } 25 | else if (!(obj instanceof Triple)) { 26 | return false; 27 | } 28 | 29 | Triple other = (Triple)obj; 30 | return ObjectEqualityComparator.INSTANCE.equals(a, other.a) 31 | && ObjectEqualityComparator.INSTANCE.equals(b, other.b) 32 | && ObjectEqualityComparator.INSTANCE.equals(c, other.c); 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | int hash = MurmurHash.initialize(); 38 | hash = MurmurHash.update(hash, a); 39 | hash = MurmurHash.update(hash, b); 40 | hash = MurmurHash.update(hash, c); 41 | return MurmurHash.finish(hash, 3); 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return String.format("(%s, %s, %s)", a, b, c); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ErrorNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | public interface ErrorNode extends TerminalNode { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ErrorNodeImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.Token; 10 | 11 | /** Represents a token that was consumed during resynchronization 12 | * rather than during a valid match operation. For example, 13 | * we will create this kind of a node during single token insertion 14 | * and deletion as well as during "consume until error recovery set" 15 | * upon no viable alternative exceptions. 16 | */ 17 | public class ErrorNodeImpl extends TerminalNodeImpl implements ErrorNode { 18 | public ErrorNodeImpl(Token token) { 19 | super(token); 20 | } 21 | 22 | @Override 23 | public T accept(ParseTreeVisitor visitor) { 24 | return visitor.visitErrorNode(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ParseTree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.Parser; 10 | import org.antlr.v4.runtime.RuleContext; 11 | import org.antlr.v4.runtime.Token; 12 | 13 | /** An interface to access the tree of {@link RuleContext} objects created 14 | * during a parse that makes the data structure look like a simple parse tree. 15 | * This node represents both internal nodes, rule invocations, 16 | * and leaf nodes, token matches. 17 | * 18 | *

The payload is either a {@link Token} or a {@link RuleContext} object.

19 | */ 20 | public interface ParseTree extends SyntaxTree { 21 | // the following methods narrow the return type; they are not additional methods 22 | @Override 23 | ParseTree getParent(); 24 | @Override 25 | ParseTree getChild(int i); 26 | 27 | 28 | /** Set the parent for this node. 29 | * 30 | * This is not backward compatible as it changes 31 | * the interface but no one was able to create custom 32 | * nodes anyway so I'm adding as it improves internal 33 | * code quality. 34 | * 35 | * One could argue for a restructuring of 36 | * the class/interface hierarchy so that 37 | * setParent, addChild are moved up to Tree 38 | * but that's a major change. So I'll do the 39 | * minimal change, which is to add this method. 40 | * 41 | * @since 4.7 42 | */ 43 | void setParent(RuleContext parent); 44 | 45 | /** The {@link ParseTreeVisitor} needs a double dispatch method. */ 46 | T accept(ParseTreeVisitor visitor); 47 | 48 | /** Return the combined text of all leaf nodes. Does not get any 49 | * off-channel tokens (if any) so won't return whitespace and 50 | * comments if they are sent to parser on hidden channel. 51 | */ 52 | String getText(); 53 | 54 | /** Specialize toStringTree so that it can print out more information 55 | * based upon the parser. 56 | */ 57 | String toStringTree(Parser parser); 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ParseTreeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.ParserRuleContext; 10 | 11 | /** This interface describes the minimal core of methods triggered 12 | * by {@link ParseTreeWalker}. E.g., 13 | * 14 | * ParseTreeWalker walker = new ParseTreeWalker(); 15 | * walker.walk(myParseTreeListener, myParseTree); <-- triggers events in your listener 16 | * 17 | * If you want to trigger events in multiple listeners during a single 18 | * tree walk, you can use the ParseTreeDispatcher object available at 19 | * 20 | * https://github.com/antlr/antlr4/issues/841 21 | */ 22 | public interface ParseTreeListener { 23 | void visitTerminal(TerminalNode node); 24 | void visitErrorNode(ErrorNode node); 25 | void enterEveryRule(ParserRuleContext ctx); 26 | void exitEveryRule(ParserRuleContext ctx); 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ParseTreeProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import java.util.IdentityHashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * Associate a property with a parse tree node. Useful with parse tree listeners 14 | * that need to associate values with particular tree nodes, kind of like 15 | * specifying a return value for the listener event method that visited a 16 | * particular node. Example: 17 | * 18 | *
19 |  * ParseTreeProperty<Integer> values = new ParseTreeProperty<Integer>();
20 |  * values.put(tree, 36);
21 |  * int x = values.get(tree);
22 |  * values.removeFrom(tree);
23 |  * 
24 | * 25 | * You would make one decl (values here) in the listener and use lots of times 26 | * in your event methods. 27 | */ 28 | public class ParseTreeProperty { 29 | protected Map annotations = new IdentityHashMap(); 30 | 31 | public V get(ParseTree node) { return annotations.get(node); } 32 | public void put(ParseTree node, V value) { annotations.put(node, value); } 33 | public V removeFrom(ParseTree node) { return annotations.remove(node); } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ParseTreeVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | /** 10 | * This interface defines the basic notion of a parse tree visitor. Generated 11 | * visitors implement this interface and the {@code XVisitor} interface for 12 | * grammar {@code X}. 13 | * 14 | * @param The return type of the visit operation. Use {@link Void} for 15 | * operations with no return type. 16 | */ 17 | public interface ParseTreeVisitor { 18 | 19 | /** 20 | * Visit a parse tree, and return a user-defined result of the operation. 21 | * 22 | * @param tree The {@link ParseTree} to visit. 23 | * @return The result of visiting the parse tree. 24 | */ 25 | T visit(ParseTree tree); 26 | 27 | /** 28 | * Visit the children of a node, and return a user-defined result of the 29 | * operation. 30 | * 31 | * @param node The {@link RuleNode} whose children should be visited. 32 | * @return The result of visiting the children of the node. 33 | */ 34 | T visitChildren(RuleNode node); 35 | 36 | /** 37 | * Visit a terminal node, and return a user-defined result of the operation. 38 | * 39 | * @param node The {@link TerminalNode} to visit. 40 | * @return The result of visiting the node. 41 | */ 42 | T visitTerminal(TerminalNode node); 43 | 44 | /** 45 | * Visit an error node, and return a user-defined result of the operation. 46 | * 47 | * @param node The {@link ErrorNode} to visit. 48 | * @return The result of visiting the node. 49 | */ 50 | T visitErrorNode(ErrorNode node); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/ParseTreeWalker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.ParserRuleContext; 10 | import org.antlr.v4.runtime.RuleContext; 11 | 12 | public class ParseTreeWalker { 13 | public static final ParseTreeWalker DEFAULT = new ParseTreeWalker(); 14 | 15 | public void walk(ParseTreeListener listener, ParseTree t) { 16 | if ( t instanceof ErrorNode) { 17 | listener.visitErrorNode((ErrorNode)t); 18 | return; 19 | } 20 | else if ( t instanceof TerminalNode) { 21 | listener.visitTerminal((TerminalNode)t); 22 | return; 23 | } 24 | RuleNode r = (RuleNode)t; 25 | enterRule(listener, r); 26 | int n = r.getChildCount(); 27 | for (int i = 0; iAn interval of i..i-1 indicates an empty interval at position 24 | * i in the input stream, where 0 <= i <= the size of the input 25 | * token stream. Currently, the code base can only have i=0..n-1 but 26 | * in concept one could have an empty interval after EOF.

27 | * 28 | *

If source interval is unknown, this returns {@link Interval#INVALID}.

29 | * 30 | *

As a weird special case, the source interval for rules matched after 31 | * EOF is unspecified.

32 | */ 33 | Interval getSourceInterval(); 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/TerminalNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.Token; 10 | 11 | public interface TerminalNode extends ParseTree { 12 | Token getSymbol(); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/TerminalNodeImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.Parser; 10 | import org.antlr.v4.runtime.RuleContext; 11 | import org.antlr.v4.runtime.Token; 12 | import org.antlr.v4.runtime.misc.Interval; 13 | 14 | public class TerminalNodeImpl implements TerminalNode { 15 | public Token symbol; 16 | public ParseTree parent; 17 | 18 | public TerminalNodeImpl(Token symbol) { this.symbol = symbol; } 19 | 20 | @Override 21 | public ParseTree getChild(int i) {return null;} 22 | 23 | @Override 24 | public Token getSymbol() {return symbol;} 25 | 26 | @Override 27 | public ParseTree getParent() { return parent; } 28 | 29 | @Override 30 | public void setParent(RuleContext parent) { 31 | this.parent = parent; 32 | } 33 | 34 | @Override 35 | public Token getPayload() { return symbol; } 36 | 37 | @Override 38 | public Interval getSourceInterval() { 39 | if ( symbol ==null ) return Interval.INVALID; 40 | 41 | int tokenIndex = symbol.getTokenIndex(); 42 | return new Interval(tokenIndex, tokenIndex); 43 | } 44 | 45 | @Override 46 | public int getChildCount() { return 0; } 47 | 48 | @Override 49 | public T accept(ParseTreeVisitor visitor) { 50 | return visitor.visitTerminal(this); 51 | } 52 | 53 | @Override 54 | public String getText() { return symbol.getText(); } 55 | 56 | @Override 57 | public String toStringTree(Parser parser) { 58 | return toString(); 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | if ( symbol.getType() == Token.EOF ) return ""; 64 | return symbol.getText(); 65 | } 66 | 67 | @Override 68 | public String toStringTree() { 69 | return toString(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/Tree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree; 8 | 9 | import org.antlr.v4.runtime.RuleContext; 10 | import org.antlr.v4.runtime.Token; 11 | 12 | /** The basic notion of a tree has a parent, a payload, and a list of children. 13 | * It is the most abstract interface for all the trees used by ANTLR. 14 | */ 15 | public interface Tree { 16 | /** The parent of this node. If the return value is null, then this 17 | * node is the root of the tree. 18 | */ 19 | Tree getParent(); 20 | 21 | /** 22 | * This method returns whatever object represents the data at this note. For 23 | * example, for parse trees, the payload can be a {@link Token} representing 24 | * a leaf node or a {@link RuleContext} object representing a rule 25 | * invocation. For abstract syntax trees (ASTs), this is a {@link Token} 26 | * object. 27 | */ 28 | Object getPayload(); 29 | 30 | /** If there are children, get the {@code i}th value indexed from 0. */ 31 | Tree getChild(int i); 32 | 33 | /** How many children are there? If there is none, then this 34 | * node represents a leaf node. 35 | */ 36 | int getChildCount(); 37 | 38 | /** Print out a whole tree, not just a node, in LISP format 39 | * {@code (root child1 .. childN)}. Print just a node if this is a leaf. 40 | */ 41 | String toStringTree(); 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/pattern/Chunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.pattern; 8 | 9 | /** 10 | * A chunk is either a token tag, a rule tag, or a span of literal text within a 11 | * tree pattern. 12 | * 13 | *

The method {@link ParseTreePatternMatcher#split(String)} returns a list of 14 | * chunks in preparation for creating a token stream by 15 | * {@link ParseTreePatternMatcher#tokenize(String)}. From there, we get a parse 16 | * tree from with {@link ParseTreePatternMatcher#compile(String, int)}. These 17 | * chunks are converted to {@link RuleTagToken}, {@link TokenTagToken}, or the 18 | * regular tokens of the text surrounding the tags.

19 | */ 20 | abstract class Chunk { 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/pattern/TextChunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.pattern; 8 | 9 | /** 10 | * Represents a span of raw text (concrete syntax) between tags in a tree 11 | * pattern string. 12 | */ 13 | class TextChunk extends Chunk { 14 | /** 15 | * This is the backing field for {@link #getText}. 16 | */ 17 | 18 | private final String text; 19 | 20 | /** 21 | * Constructs a new instance of {@link TextChunk} with the specified text. 22 | * 23 | * @param text The text of this chunk. 24 | * @exception IllegalArgumentException if {@code text} is {@code null}. 25 | */ 26 | public TextChunk(String text) { 27 | if (text == null) { 28 | throw new IllegalArgumentException("text cannot be null"); 29 | } 30 | 31 | this.text = text; 32 | } 33 | 34 | /** 35 | * Gets the raw text of this chunk. 36 | * 37 | * @return The text of the chunk. 38 | */ 39 | 40 | public final String getText() { 41 | return text; 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | * 47 | *

The implementation for {@link TextChunk} returns the result of 48 | * {@link #getText()} in single quotes.

49 | */ 50 | @Override 51 | public String toString() { 52 | return "'"+text+"'"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | 11 | import java.util.Collection; 12 | 13 | public abstract class XPathElement { 14 | protected String nodeName; 15 | protected boolean invert; 16 | 17 | /** Construct element like {@code /ID} or {@code ID} or {@code /*} etc... 18 | * op is null if just node 19 | */ 20 | public XPathElement(String nodeName) { 21 | this.nodeName = nodeName; 22 | } 23 | 24 | /** 25 | * Given tree rooted at {@code t} return all nodes matched by this path 26 | * element. 27 | */ 28 | public abstract Collection evaluate(ParseTree t); 29 | 30 | @Override 31 | public String toString() { 32 | String inv = invert ? "!" : ""; 33 | return getClass().getSimpleName()+"["+inv+nodeName+"]"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathLexerErrorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.BaseErrorListener; 10 | import org.antlr.v4.runtime.RecognitionException; 11 | import org.antlr.v4.runtime.Recognizer; 12 | 13 | public class XPathLexerErrorListener extends BaseErrorListener { 14 | @Override 15 | public void syntaxError(Recognizer recognizer, Object offendingSymbol, 16 | int line, int charPositionInLine, String msg, 17 | RecognitionException e) 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathRuleAnywhereElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | import org.antlr.v4.runtime.tree.Trees; 11 | 12 | import java.util.Collection; 13 | 14 | /** 15 | * Either {@code ID} at start of path or {@code ...//ID} in middle of path. 16 | */ 17 | public class XPathRuleAnywhereElement extends XPathElement { 18 | protected int ruleIndex; 19 | public XPathRuleAnywhereElement(String ruleName, int ruleIndex) { 20 | super(ruleName); 21 | this.ruleIndex = ruleIndex; 22 | } 23 | 24 | @Override 25 | public Collection evaluate(ParseTree t) { 26 | return Trees.findAllRuleNodes(t, ruleIndex); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathRuleElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.ParserRuleContext; 10 | import org.antlr.v4.runtime.tree.ParseTree; 11 | import org.antlr.v4.runtime.tree.Tree; 12 | import org.antlr.v4.runtime.tree.Trees; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Collection; 16 | import java.util.List; 17 | 18 | public class XPathRuleElement extends XPathElement { 19 | protected int ruleIndex; 20 | public XPathRuleElement(String ruleName, int ruleIndex) { 21 | super(ruleName); 22 | this.ruleIndex = ruleIndex; 23 | } 24 | 25 | @Override 26 | public Collection evaluate(ParseTree t) { 27 | // return all children of t that match nodeName 28 | List nodes = new ArrayList(); 29 | for (Tree c : Trees.getChildren(t)) { 30 | if ( c instanceof ParserRuleContext ) { 31 | ParserRuleContext ctx = (ParserRuleContext)c; 32 | if ( (ctx.getRuleIndex() == ruleIndex && !invert) || 33 | (ctx.getRuleIndex() != ruleIndex && invert) ) 34 | { 35 | nodes.add(ctx); 36 | } 37 | } 38 | } 39 | return nodes; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathTokenAnywhereElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | import org.antlr.v4.runtime.tree.Trees; 11 | 12 | import java.util.Collection; 13 | 14 | public class XPathTokenAnywhereElement extends XPathElement { 15 | protected int tokenType; 16 | public XPathTokenAnywhereElement(String tokenName, int tokenType) { 17 | super(tokenName); 18 | this.tokenType = tokenType; 19 | } 20 | 21 | @Override 22 | public Collection evaluate(ParseTree t) { 23 | return Trees.findAllTokenNodes(t, tokenType); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathTokenElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | import org.antlr.v4.runtime.tree.TerminalNode; 11 | import org.antlr.v4.runtime.tree.Tree; 12 | import org.antlr.v4.runtime.tree.Trees; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Collection; 16 | import java.util.List; 17 | 18 | public class XPathTokenElement extends XPathElement { 19 | protected int tokenType; 20 | public XPathTokenElement(String tokenName, int tokenType) { 21 | super(tokenName); 22 | this.tokenType = tokenType; 23 | } 24 | 25 | @Override 26 | public Collection evaluate(ParseTree t) { 27 | // return all children of t that match nodeName 28 | List nodes = new ArrayList(); 29 | for (Tree c : Trees.getChildren(t)) { 30 | if ( c instanceof TerminalNode ) { 31 | TerminalNode tnode = (TerminalNode)c; 32 | if ( (tnode.getSymbol().getType() == tokenType && !invert) || 33 | (tnode.getSymbol().getType() != tokenType && invert) ) 34 | { 35 | nodes.add(tnode); 36 | } 37 | } 38 | } 39 | return nodes; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathWildcardAnywhereElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | import org.antlr.v4.runtime.tree.Trees; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Collection; 14 | 15 | public class XPathWildcardAnywhereElement extends XPathElement { 16 | public XPathWildcardAnywhereElement() { 17 | super(XPath.WILDCARD); 18 | } 19 | 20 | @Override 21 | public Collection evaluate(ParseTree t) { 22 | if ( invert ) return new ArrayList(); // !* is weird but valid (empty) 23 | return Trees.getDescendants(t); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/org/antlr/v4/runtime/tree/xpath/XPathWildcardElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 | * Use of this file is governed by the BSD 3-clause license that 4 | * can be found in the LICENSE.txt file in the project root. 5 | */ 6 | 7 | package org.antlr.v4.runtime.tree.xpath; 8 | 9 | import org.antlr.v4.runtime.tree.ParseTree; 10 | import org.antlr.v4.runtime.tree.Tree; 11 | import org.antlr.v4.runtime.tree.Trees; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Collection; 15 | import java.util.List; 16 | 17 | public class XPathWildcardElement extends XPathElement { 18 | public XPathWildcardElement() { 19 | super(XPath.WILDCARD); 20 | } 21 | 22 | @Override 23 | public Collection evaluate(final ParseTree t) { 24 | if ( invert ) return new ArrayList(); // !* is weird but valid (empty) 25 | List kids = new ArrayList(); 26 | for (Tree c : Trees.getChildren(t)) { 27 | kids.add((ParseTree)c); 28 | } 29 | return kids; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/editor_context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1sp 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TextView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/test/java/com/a4455jkjh/textview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.a4455jkjh.textview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.5.3' 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /dom/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /dom/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | consumerProguardFiles 'consumer-rules.pro' 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | api fileTree(dir: 'libs', include: ['*.jar']) 29 | } 30 | -------------------------------------------------------------------------------- /dom/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/dom/consumer-rules.pro -------------------------------------------------------------------------------- /dom/libs/ecj.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/dom/libs/ecj.jar -------------------------------------------------------------------------------- /dom/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /dom/src/androidTest/java/org/eclipse/jdt/core/dom/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.jdt.core.dom; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("org.eclipse.jdt.core.dom.test", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /dom/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/ExecutionException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2004, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.commands; 12 | 13 | import org.eclipse.core.commands.common.CommandException; 14 | 15 | /** 16 | * Signals that an exception occured during the execution of a command. 17 | *

18 | * This class is not intended to be extended by clients. 19 | *

20 | * 21 | * @since 3.1 22 | */ 23 | public final class ExecutionException extends CommandException { 24 | 25 | /** 26 | * Generated serial version UID for this class. 27 | * 28 | * @since 3.1 29 | */ 30 | private static final long serialVersionUID = 3258130262767448120L; 31 | 32 | /** 33 | * Creates a new instance of this class with the specified detail message. 34 | * 35 | * @param message 36 | * the detail message; may be null. 37 | * @since 3.2 38 | */ 39 | public ExecutionException(final String message) { 40 | super(message); 41 | } 42 | 43 | /** 44 | * Creates a new instance of this class with the specified detail message 45 | * and cause. 46 | * 47 | * @param message 48 | * the detail message; may be null. 49 | * @param cause 50 | * the cause; may be null. 51 | */ 52 | public ExecutionException(final String message, final Throwable cause) { 53 | super(message, cause); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/operations/ICompositeOperation.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.commands.operations; 12 | 13 | /** 14 | *

15 | * ICompositeOperation defines an undoable operation that is composed of child 16 | * operations. Requests to execute, undo, or redo a composite result in the the 17 | * execution, undo, or redo of the composite as a whole. Similarly, a request to 18 | * dispose the composite should result in all child operations being disposed. 19 | *

20 | * 21 | * @since 3.1 22 | */ 23 | public interface ICompositeOperation extends IUndoableOperation { 24 | 25 | /** 26 | *

27 | * Add the specified operation as a child of this operation. 28 | *

29 | * 30 | * @param operation 31 | * the operation to be added. If the operation instance has 32 | * already been added, this method will have no effect. 33 | */ 34 | void add(IUndoableOperation operation); 35 | 36 | /** 37 | *

38 | * Remove the specified operation from this operation. 39 | *

40 | *

41 | * The composite operation should dispose the operation as part of removing 42 | * it. 43 | *

44 | * 45 | * @param operation 46 | * the operation to be removed. The operation should be disposed 47 | * by the receiver. This method will have no effect if the 48 | * operation instance is not already a child. 49 | */ 50 | void remove(IUndoableOperation operation); 51 | } 52 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/operations/IContextReplacingOperation.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.commands.operations; 12 | 13 | /** 14 | * IContextReplacingOperation defines an interface for undoable operations that 15 | * can replace one undo context with another undo context. It is used by 16 | * operations, such as composite operations, where removing and adding an undo 17 | * context would not have the same semantic as replacing one undo context with 18 | * another. 19 | * 20 | * @since 3.2 21 | * 22 | */ 23 | public interface IContextReplacingOperation { 24 | 25 | /** 26 | * Replace the undo context of the receiver with the provided replacement 27 | * undo context. 28 | *

29 | * This message has no effect if the original undo context is not present in 30 | * the receiver. 31 | * 32 | * @param original the undo context which is to be replaced 33 | * @param replacement the undo context which is replacing the original 34 | * 35 | */ 36 | void replaceContext(IUndoContext original, IUndoContext replacement); 37 | } 38 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/operations/IOperationHistoryListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.commands.operations; 12 | 13 | /** 14 | *

15 | * This interface is used to listen to notifications from an IOperationHistory. 16 | * The supplied OperationHistoryEvent describes the particular notification. 17 | *

18 | *

19 | * Operation history listeners must be prepared to receive notifications from a 20 | * background thread. Any UI access occurring inside the implementation must be 21 | * properly synchronized using the techniques specified by the client's widget 22 | * library. 23 | *

24 | * 25 | * @since 3.1 26 | */ 27 | public interface IOperationHistoryListener { 28 | /** 29 | * Something of note has happened in the IOperationHistory. Listeners should 30 | * check the supplied event for details. 31 | * 32 | * @param event 33 | * the OperationHistoryEvent that describes the particular 34 | * notification. 35 | */ 36 | void historyNotification(OperationHistoryEvent event); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/operations/UndoContext.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.commands.operations; 12 | 13 | /** 14 | *

15 | * A simple, lightweight undo context that can be used to tag any operation. It 16 | * does not provided a specialized label. This class may be instantiated by 17 | * clients. This class may also be subclassed. 18 | *

19 | * 20 | * @since 3.1 21 | */ 22 | public class UndoContext implements IUndoContext { 23 | 24 | /** 25 | *

26 | * Get the label that describes the undo context. The default implementation 27 | * returns the empty String. Subclasses may override. 28 | *

29 | * 30 | * @return the label for the context. 31 | */ 32 | @Override 33 | public String getLabel() { 34 | return ""; //$NON-NLS-1$ 35 | } 36 | 37 | /** 38 | *

39 | * Return whether the specified context is considered a match for the 40 | * receiving context. When a context matches another context, operations 41 | * that have the context are considered to also have the matching context. 42 | * The default implementation checks whether the supplied context is 43 | * identical to this context. Subclasses may override. 44 | *

45 | * 46 | * @param context 47 | * the context to be checked against the receiving context. 48 | * 49 | * @return true if the receiving context can be considered a 50 | * match for the specified context, and false if it 51 | * cannot. 52 | */ 53 | @Override 54 | public boolean matches(IUndoContext context) { 55 | return context == this; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/commands/util/Tracing.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.core.commands.util; 13 | 14 | /** 15 | *

16 | * A utility class for printing tracing output to the console. 17 | *

18 | *

19 | * Clients must not extend or instantiate this class. 20 | *

21 | * 22 | * @since 3.2 23 | */ 24 | public final class Tracing { 25 | 26 | /** 27 | * The separator to place between the component and the message. 28 | */ 29 | public static final String SEPARATOR = " >>> "; //$NON-NLS-1$ 30 | 31 | /** 32 | *

33 | * Prints a tracing message to standard out. The message is prefixed by a 34 | * component identifier and some separator. See the example below. 35 | *

36 | * 37 | *
38 | 	 *        BINDINGS >> There are 4 deletion markers
39 | 	 * 
40 | * 41 | * @param component 42 | * The component for which this tracing applies; may be 43 | * null 44 | * @param message 45 | * The message to print to standard out; may be null. 46 | */ 47 | public static final void printTrace(final String component, 48 | final String message) { 49 | StringBuffer buffer = new StringBuffer(); 50 | if (component != null) { 51 | buffer.append(component); 52 | } 53 | if ((component != null) && (message != null)) { 54 | buffer.append(SEPARATOR); 55 | } 56 | if (message != null) { 57 | buffer.append(message); 58 | } 59 | System.out.println(buffer.toString()); 60 | } 61 | 62 | /** 63 | * This class is not intended to be instantiated. 64 | */ 65 | private Tracing() { 66 | // Do nothing. 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/internal/commands/operations/GlobalUndoContext.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2005, 2015 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.internal.commands.operations; 12 | 13 | import org.eclipse.core.commands.operations.IUndoContext; 14 | 15 | /** 16 | *

17 | * An operation context that matches to any context. It can be used to 18 | * get an unfiltered (global) history. 19 | *

20 | * 21 | * @since 3.1 22 | */ 23 | public class GlobalUndoContext implements IUndoContext { 24 | 25 | @Override 26 | public String getLabel() { 27 | return "Global Undo Context"; //$NON-NLS-1$ 28 | } 29 | 30 | @Override 31 | public boolean matches(IUndoContext context) { 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/internal/runtime/PrintStackUtil.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008, 2009 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.internal.runtime; 12 | 13 | import java.io.PrintStream; 14 | import java.io.PrintWriter; 15 | import org.eclipse.core.runtime.IStatus; 16 | 17 | public class PrintStackUtil { 18 | 19 | static public void printChildren(IStatus status, PrintStream output) { 20 | IStatus[] children = status.getChildren(); 21 | if (children == null || children.length == 0) 22 | return; 23 | for (int i = 0; i < children.length; i++) { 24 | output.println("Contains: " + children[i].getMessage()); //$NON-NLS-1$ 25 | Throwable exception = children[i].getException(); 26 | if (exception != null) 27 | exception.printStackTrace(output); 28 | printChildren(children[i], output); 29 | } 30 | } 31 | 32 | static public void printChildren(IStatus status, PrintWriter output) { 33 | IStatus[] children = status.getChildren(); 34 | if (children == null || children.length == 0) 35 | return; 36 | for (int i = 0; i < children.length; i++) { 37 | output.println("Contains: " + children[i].getMessage()); //$NON-NLS-1$ 38 | output.flush(); // call to synchronize output 39 | Throwable exception = children[i].getException(); 40 | if (exception != null) 41 | exception.printStackTrace(output); 42 | printChildren(children[i], output); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/runtime/AssertionFailedException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.runtime; 12 | 13 | /** 14 | * AssertionFailedException is a runtime exception thrown 15 | * by some of the methods in Assert. 16 | *

17 | * This class can be used without OSGi running. 18 | *

19 | * This class is not intended to be instantiated or sub-classed by clients. 20 | *

21 | * @see Assert 22 | * @since org.eclipse.equinox.common 3.2 23 | * @noextend This class is not intended to be subclassed by clients. 24 | * @noinstantiate This class is not intended to be instantiated by clients. 25 | */ 26 | public class AssertionFailedException extends RuntimeException { 27 | 28 | /** 29 | * All serializable objects should have a stable serialVersionUID 30 | */ 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** 34 | * Constructs a new exception with the given message. 35 | * 36 | * @param detail the message 37 | */ 38 | public AssertionFailedException(String detail) { 39 | super(detail); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/core/runtime/OperationCanceledException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.core.runtime; 12 | 13 | /** 14 | * This exception is thrown to blow out of a long-running method 15 | * when the user cancels it. 16 | *

17 | * This class can be used without OSGi running. 18 | *

19 | * This class is not intended to be subclassed by clients but 20 | * may be instantiated. 21 | *

22 | */ 23 | public final class OperationCanceledException extends RuntimeException { 24 | /** 25 | * All serializable objects should have a stable serialVersionUID 26 | */ 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Creates a new exception. 31 | */ 32 | public OperationCanceledException() { 33 | super(); 34 | } 35 | 36 | /** 37 | * Creates a new exception with the given message. 38 | * 39 | * @param message the message for the exception 40 | */ 41 | public OperationCanceledException(String message) { 42 | super(message); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jdt/core/dom/IDocElement.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2004, 2014 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.jdt.core.dom; 13 | 14 | /** 15 | * Common marker interface for AST nodes that represent fragments in doc elements. 16 | * These are node types that can legitimately be included in {@link TagElement#fragments()}. 17 | *
18 |  * IDocElement:
19 |  *   {@link MemberRef}
20 |  *   {@link MethodRef}
21 |  *   {@link Name}
22 |  *   {@link TagElement}
23 |  *   {@link TextElement}
24 |  * 
25 | * 26 | * @since 3.11, internal interface since 3.0 27 | * @see TagElement#fragments() 28 | * @noextend This interface is not intended to be extended by clients. 29 | * @noimplement This interface is not intended to be implemented by clients. 30 | */ 31 | public interface IDocElement { 32 | // marker-type interfaces have no members 33 | } 34 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jdt/core/dom/IExtendedModifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2004, 2014 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jdt.core.dom; 12 | 13 | /** 14 | * Common interface for AST nodes that represent modifiers or 15 | * annotations. 16 | *
17 |  * IExtendedModifier:
18 |  *   Modifier
19 |  *   Annotation
20 |  * 
21 | * @since 3.1 22 | * @noextend This interface is not intended to be extended by clients. 23 | * @noimplement This interface is not intended to be implemented by clients. 24 | */ 25 | public interface IExtendedModifier { 26 | 27 | /** 28 | * Returns whether this extended modifier is a standard modifier. 29 | * 30 | * @return true if this is a standard modifier 31 | * (instance of {@link Modifier}), and false otherwise 32 | */ 33 | public boolean isModifier(); 34 | 35 | /** 36 | * Returns whether this extended modifier is an annotation. 37 | * 38 | * @return true if this is an annotation 39 | * (instance of a subclass of {@link Annotation}), and 40 | * false otherwise 41 | */ 42 | public boolean isAnnotation(); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jdt/internal/core/util/RecordedParsingInformation.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2002, 2009 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jdt.internal.core.util; 12 | 13 | import org.eclipse.jdt.core.compiler.CategorizedProblem; 14 | import org.eclipse.jdt.internal.compiler.CompilationResult; 15 | 16 | /** 17 | * Use to keep track of recorded information during the parsing like comment positions, 18 | * line ends or problems. 19 | */ 20 | public class RecordedParsingInformation { 21 | public CategorizedProblem[] problems; 22 | public int problemsCount; 23 | public int[] lineEnds; 24 | public int[][] commentPositions; 25 | 26 | public RecordedParsingInformation(CategorizedProblem[] problems, int[] lineEnds, int[][] commentPositions) { 27 | this.problems = problems; 28 | this.lineEnds = lineEnds; 29 | this.commentPositions = commentPositions; 30 | this.problemsCount = problems != null ? problems.length : 0; 31 | } 32 | 33 | void updateRecordedParsingInformation(CompilationResult compilationResult) { 34 | if (compilationResult.problems != null) { 35 | this.problems = compilationResult.problems; 36 | this.problemsCount = this.problems.length; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/BadLocationException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | 15 | /** 16 | * Indicates the attempt to access a non-existing position. The attempt has been 17 | * performed on a text store such as a document or string. 18 | *

19 | * This class is not intended to be serialized. 20 | *

21 | */ 22 | public class BadLocationException extends Exception { 23 | 24 | /** 25 | * Serial version UID for this class. 26 | *

27 | * Note: This class is not intended to be serialized. 28 | *

29 | * @since 3.1 30 | */ 31 | private static final long serialVersionUID= 3257281452776370224L; 32 | 33 | /** 34 | * Creates a new bad location exception. 35 | */ 36 | public BadLocationException() { 37 | super(); 38 | } 39 | 40 | /** 41 | * Creates a new bad location exception. 42 | * 43 | * @param message the exception message 44 | */ 45 | public BadLocationException(String message) { 46 | super(message); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/BadPartitioningException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | /** 14 | * Represents the attempt to refer to a non-existing document partitioning. 15 | *

16 | * This class is not intended to be serialized. 17 | *

18 | * 19 | * @see org.eclipse.jface.text.IDocument 20 | * @see org.eclipse.jface.text.IDocumentExtension3 21 | * @since 3.0 22 | */ 23 | public class BadPartitioningException extends Exception { 24 | 25 | /** 26 | * Serial version UID for this class. 27 | *

28 | * Note: This class is not intended to be serialized. 29 | *

30 | * @since 3.1 31 | */ 32 | private static final long serialVersionUID= 3256439205327876408L; 33 | 34 | /** 35 | * Creates a new bad partitioning exception. 36 | */ 37 | public BadPartitioningException() { 38 | } 39 | 40 | /** 41 | * Creates a new bad partitioning exception. 42 | * 43 | * @param message message describing the exception 44 | */ 45 | public BadPartitioningException(String message) { 46 | super(message); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/BadPositionCategoryException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | 15 | /** 16 | * Indicates the attempt to access a non-existing position 17 | * category in a document. 18 | *

19 | * This class is not intended to be serialized. 20 | *

21 | * 22 | * @see org.eclipse.jface.text.IDocument 23 | */ 24 | public class BadPositionCategoryException extends Exception { 25 | 26 | /** 27 | * Serial version UID for this class. 28 | *

29 | * Note: This class is not intended to be serialized. 30 | *

31 | * @since 3.1 32 | */ 33 | private static final long serialVersionUID= 3761405300745713206L; 34 | 35 | /** 36 | * Creates a new bad position category exception. 37 | */ 38 | public BadPositionCategoryException() { 39 | super(); 40 | } 41 | 42 | /** 43 | * Creates a new bad position category exception. 44 | * 45 | * @param message the exception's message 46 | */ 47 | public BadPositionCategoryException(String message) { 48 | super(message); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/DocumentRewriteSession.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * A document rewrite session. 16 | * 17 | * @see org.eclipse.jface.text.IDocument 18 | * @see org.eclipse.jface.text.IDocumentExtension4 19 | * @see org.eclipse.jface.text.IDocumentRewriteSessionListener 20 | * @since 3.1 21 | */ 22 | public class DocumentRewriteSession { 23 | 24 | private DocumentRewriteSessionType fSessionType; 25 | 26 | /** 27 | * Prohibit package external object creation. 28 | * 29 | * @param sessionType the type of this session 30 | */ 31 | protected DocumentRewriteSession(DocumentRewriteSessionType sessionType) { 32 | fSessionType= sessionType; 33 | } 34 | 35 | /** 36 | * Returns the type of this session. 37 | * 38 | * @return the type of this session 39 | */ 40 | public DocumentRewriteSessionType getSessionType() { 41 | return fSessionType; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return new StringBuffer().append(hashCode()).toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentExtension2.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2010 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.jface.text; 13 | 14 | /** 15 | * Extension interface for {@link org.eclipse.jface.text.IDocument}.

16 | * 17 | * It adds configuration methods to post notification replaces and document 18 | * listener notification. 19 | * 20 | * @since 2.1 21 | */ 22 | public interface IDocumentExtension2 { 23 | 24 | /** 25 | * Tells the receiver to ignore calls to 26 | * registerPostNotificationReplace until 27 | * acceptPostNotificationReplaces is called. 28 | */ 29 | void ignorePostNotificationReplaces(); 30 | 31 | /** 32 | * Tells the receiver to accept calls to 33 | * registerPostNotificationReplace until 34 | * ignorePostNotificationReplaces is called. 35 | */ 36 | void acceptPostNotificationReplaces(); 37 | 38 | /** 39 | * Can be called prior to a replace operation. After the 40 | * replace resumeListenerNotification must be 41 | * called. The effect of these calls is that no document listener is notified 42 | * until resumeListenerNotification is called. This allows clients 43 | * to update structure before any listener is informed about the change.

44 | * Listener notification can only be stopped for a single replace operation. 45 | * Otherwise, document change notifications will be lost. 46 | */ 47 | void stopListenerNotification(); 48 | 49 | /** 50 | * Resumes the notification of document listeners which must previously 51 | * have been stopped by a call to stopListenerNotification. 52 | */ 53 | void resumeListenerNotification(); 54 | } 55 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | 15 | /** 16 | * Interface for objects which are interested in getting informed about 17 | * document changes. A listener is informed about document changes before 18 | * they are applied and after they have been applied. It is ensured that 19 | * the document event passed into the listener is the same for the two 20 | * notifications, i.e. the two document events can be checked using object identity. 21 | *

22 | * Clients may implement this interface. 23 | *

24 | * 25 | * @see org.eclipse.jface.text.IDocument 26 | */ 27 | public interface IDocumentListener { 28 | 29 | 30 | /** 31 | * The manipulation described by the document event will be performed. 32 | * 33 | * @param event the document event describing the document change 34 | */ 35 | void documentAboutToBeChanged(DocumentEvent event); 36 | 37 | /** 38 | * The manipulation described by the document event has been performed. 39 | * 40 | * @param event the document event describing the document change 41 | */ 42 | void documentChanged(DocumentEvent event); 43 | } 44 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentPartitionerExtension.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.jface.text; 13 | 14 | 15 | /** 16 | * Extension interface for {@link org.eclipse.jface.text.IDocumentPartitioner}. 17 | *

18 | * Replaces the original concept of the document partitioner by returning the 19 | * minimal region that includes all partition changes caused by the invocation 20 | * of the document partitioner. 21 | * The method documentChanged2 is considered the replacement of 22 | * {@link org.eclipse.jface.text.IDocumentPartitioner#documentChanged(DocumentEvent)}. 23 | * 24 | * @since 2.0 25 | */ 26 | public interface IDocumentPartitionerExtension { 27 | 28 | /** 29 | * The document has been changed. The partitioner updates the document's 30 | * partitioning and returns the minimal region that comprises all partition 31 | * changes caused in response to the given document event. This method 32 | * returns null if the partitioning did not change. 33 | *

34 | * 35 | * Will be called by the connected document and is not intended to be used 36 | * by clients other than the connected document. 37 | *

38 | * Replaces {@link IDocumentPartitioner#documentChanged(DocumentEvent)}. 39 | * 40 | * @param event the event describing the document change 41 | * @return the region of the document in which the partition type changed or null 42 | */ 43 | IRegion documentChanged2(DocumentEvent event); 44 | } 45 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentPartitioningListenerExtension.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | 12 | package org.eclipse.jface.text; 13 | 14 | 15 | /** 16 | * Extension interface for 17 | * {@link org.eclipse.jface.text.IDocumentPartitioningListener}. 18 | *

19 | * Replaces the original notification mechanism by telling the listener the 20 | * minimal region that comprises all partitioning changes. 21 | * 22 | * @see org.eclipse.jface.text.IDocumentPartitionerExtension 23 | * @since 2.0 24 | */ 25 | public interface IDocumentPartitioningListenerExtension { 26 | 27 | /** 28 | * The partitioning of the given document changed in the given region. 29 | *

30 | * In version 3.0, this method has been replaced with 31 | * {@link IDocumentPartitioningListenerExtension2#documentPartitioningChanged(DocumentPartitioningChangedEvent)}. 32 | * 33 | * @param document the document whose partitioning changed 34 | * @param region the region in which the partitioning changed 35 | * @see IDocumentPartitioningListenerExtension2#documentPartitioningChanged(DocumentPartitioningChangedEvent) 36 | * @see IDocument#addDocumentPartitioningListener(IDocumentPartitioningListener) 37 | */ 38 | void documentPartitioningChanged(IDocument document, IRegion region); 39 | } 40 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentPartitioningListenerExtension2.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | /** 14 | * Extension interface to 15 | * {@link org.eclipse.jface.text.IDocumentPartitioningListener}. 16 | *

17 | * 18 | * Replaces the previous notification mechanisms by introducing an explicit 19 | * document partitioning changed event. 20 | * 21 | * @see org.eclipse.jface.text.DocumentPartitioningChangedEvent 22 | * @since 3.0 23 | */ 24 | public interface IDocumentPartitioningListenerExtension2 { 25 | 26 | /** 27 | * Signals the change of document partitionings. 28 | *

29 | * This method replaces 30 | * {@link IDocumentPartitioningListener#documentPartitioningChanged(IDocument)} 31 | * and 32 | * {@link IDocumentPartitioningListenerExtension#documentPartitioningChanged(IDocument, IRegion)} 33 | * 34 | * @param event the event describing the change 35 | * @see IDocument#addDocumentPartitioningListener(IDocumentPartitioningListener) 36 | */ 37 | void documentPartitioningChanged(DocumentPartitioningChangedEvent event); 38 | } 39 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IDocumentRewriteSessionListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * Interface for objects which are interested in getting informed about document 16 | * rewrite sessions. 17 | *

18 | * Clients may implement this interface. 19 | *

20 | * 21 | * @see org.eclipse.jface.text.IDocument 22 | * @see org.eclipse.jface.text.IDocumentExtension4 23 | * @since 3.1 24 | */ 25 | public interface IDocumentRewriteSessionListener { 26 | 27 | /** 28 | * Signals a change in a document's rewrite session state. 29 | * 30 | * @param event the event describing the document rewrite session state change 31 | */ 32 | void documentRewriteSessionChanged(DocumentRewriteSessionEvent event); 33 | } 34 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/ILineTrackerExtension.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | /** 14 | * Extension interface for {@link org.eclipse.jface.text.ILineTracker}. Adds the 15 | * concept of rewrite sessions. A rewrite session is a sequence of replace 16 | * operations that form a semantic unit. 17 | * 18 | * @since 3.1 19 | */ 20 | public interface ILineTrackerExtension { 21 | 22 | /** 23 | * Tells the line tracker that a rewrite session started. A rewrite session 24 | * is a sequence of replace operations that form a semantic unit. The line 25 | * tracker is allowed to use that information for internal optimization. 26 | * 27 | * @param session the rewrite session 28 | * @throws IllegalStateException in case there is already an active rewrite 29 | * session 30 | */ 31 | void startRewriteSession(DocumentRewriteSession session) throws IllegalStateException; 32 | 33 | /** 34 | * Tells the line tracker that the rewrite session has finished. This method 35 | * is only called when startRewriteSession has been called 36 | * before. The text resulting from the rewrite session is passed to the line 37 | * tracker. 38 | * 39 | * @param session the rewrite session 40 | * @param text the text with which to re-initialize the line tracker 41 | */ 42 | void stopRewriteSession(DocumentRewriteSession session, String text); 43 | } 44 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IPositionUpdater.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * A position updater is responsible for adapting document positions. When 16 | * installed on a document, the position updater updates the document's 17 | * positions to changes applied to this document. Document updaters can be 18 | * selective, i.e. they might only update positions of a certain category. 19 | *

20 | * Position updaters are of primary importance for the definition of the 21 | * semantics of positions. 22 | *

23 | * Clients may implement this interface or use the standard implementation 24 | * {@link org.eclipse.jface.text.DefaultPositionUpdater}. 25 | *

26 | * 27 | * @see org.eclipse.jface.text.IDocument 28 | * @see org.eclipse.jface.text.Position 29 | */ 30 | public interface IPositionUpdater { 31 | 32 | /** 33 | * Adapts positions to the change specified by the document event. 34 | * It is ensured that the document's partitioning has been adapted to 35 | * this document change and that all the position updaters which have 36 | * a smaller index in the document's position updater list have been called. 37 | * 38 | * @param event the document event describing the document change 39 | */ 40 | void update(DocumentEvent event); 41 | } 42 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IRegion.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * A region describes a certain range in an indexed text store. Text stores are 16 | * for example documents or strings. A region is defined by its offset into the 17 | * text store and its length. 18 | *

19 | * A region is considered a value object. Its offset and length do not change 20 | * over time. 21 | *

22 | * Clients may implement this interface or use the standard implementation 23 | * {@link org.eclipse.jface.text.Region}. 24 | *

25 | */ 26 | public interface IRegion { 27 | 28 | /** 29 | * Returns the length of the region. 30 | * 31 | * @return the length of the region 32 | */ 33 | int getLength(); 34 | 35 | /** 36 | * Returns the offset of the region. 37 | * 38 | * @return the offset of the region 39 | */ 40 | int getOffset(); 41 | } 42 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IRepairableDocument.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * Tagging interface to be implemented by 16 | * {@link org.eclipse.jface.text.IDocument} implementers that offer a line 17 | * repair method on the documents. 18 | *

19 | * In order to provide backward compatibility for clients of 20 | * IRepairableDocument, extension interfaces are used to provide 21 | * a means of evolution. The following extension interfaces exist: 22 | *

    23 | *
  • {@link org.eclipse.jface.text.IRepairableDocumentExtension} since version 3.4 24 | * adds the ability to query whether the repairable document needs to be repaired.
  • 25 | *
26 | * 27 | * 28 | * @see org.eclipse.jface.text.IDocument 29 | * @see org.eclipse.jface.text.IRepairableDocumentExtension 30 | * @since 3.0 31 | */ 32 | public interface IRepairableDocument { 33 | 34 | /** 35 | * Repairs the line information of the document implementing this interface. 36 | */ 37 | void repairLineInformation(); 38 | } 39 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/IRepairableDocumentExtension.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2007, 2010 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * Extension interface for {@link org.eclipse.jface.text.IRepairableDocument}. 16 | *

17 | * Adds the ability to query whether the repairable document would have to be repaired after 18 | * replacing some text. 19 | * 20 | * @see org.eclipse.jface.text.IRepairableDocument 21 | * @since 3.4 22 | */ 23 | public interface IRepairableDocumentExtension { 24 | 25 | /** 26 | * Tells whether the line information of the document implementing this interface needs to be 27 | * repaired after replacing the given text. 28 | * 29 | * @param offset the document offset 30 | * @param length the length of the specified range 31 | * @param text the substitution text to check 32 | * @return true if the line information must be repaired after replacing 33 | * @throws BadLocationException if the offset is invalid in this document 34 | * @see IRepairableDocument#repairLineInformation() 35 | */ 36 | boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException; 37 | } 38 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/ITypedRegion.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | 15 | /** 16 | * Describes a region of an indexed text store such as a document or a string. 17 | * The region consists of offset, length, and type. The region type is defined 18 | * as a string. 19 | *

20 | * A typed region can, e.g., be used to described document partitions.

21 | *

22 | * Clients may implement this interface or use the standard implementation 23 | * {@link org.eclipse.jface.text.TypedRegion}.

24 | */ 25 | public interface ITypedRegion extends IRegion { 26 | 27 | /** 28 | * Returns the content type of the region. 29 | * 30 | * @return the content type of the region 31 | */ 32 | String getType(); 33 | } 34 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/Line.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * Describes a line as a particular number of characters beginning at 16 | * a particular offset, consisting of a particular number of characters, 17 | * and being closed with a particular line delimiter. 18 | */ 19 | final class Line implements IRegion { 20 | 21 | /** The offset of the line */ 22 | public int offset; 23 | /** The length of the line */ 24 | public int length; 25 | /** The delimiter of this line */ 26 | public final String delimiter; 27 | 28 | /** 29 | * Creates a new Line. 30 | * 31 | * @param offset the offset of the line 32 | * @param end the last including character offset of the line 33 | * @param delimiter the line's delimiter 34 | */ 35 | public Line(int offset, int end, String delimiter) { 36 | this.offset= offset; 37 | this.length= (end - offset) +1; 38 | this.delimiter= delimiter; 39 | } 40 | 41 | /** 42 | * Creates a new Line. 43 | * 44 | * @param offset the offset of the line 45 | * @param length the length of the line 46 | */ 47 | public Line(int offset, int length) { 48 | this.offset= offset; 49 | this.length= length; 50 | this.delimiter= null; 51 | } 52 | 53 | @Override 54 | public int getOffset() { 55 | return offset; 56 | } 57 | 58 | @Override 59 | public int getLength() { 60 | return length; 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/Region.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * The default implementation of the {@link org.eclipse.jface.text.IRegion} interface. 16 | */ 17 | public class Region implements IRegion { 18 | 19 | /** The region offset */ 20 | private int fOffset; 21 | /** The region length */ 22 | private int fLength; 23 | 24 | /** 25 | * Create a new region. 26 | * 27 | * @param offset the offset of the region 28 | * @param length the length of the region 29 | */ 30 | public Region(int offset, int length) { 31 | fOffset= offset; 32 | fLength= length; 33 | } 34 | 35 | @Override 36 | public int getLength() { 37 | return fLength; 38 | } 39 | 40 | @Override 41 | public int getOffset() { 42 | return fOffset; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object o) { 47 | if (o instanceof IRegion) { 48 | IRegion r= (IRegion) o; 49 | return r.getOffset() == fOffset && r.getLength() == fLength; 50 | } 51 | return false; 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return (fOffset << 24) | (fLength << 16); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "offset: " + fOffset + ", length: " + fLength; //$NON-NLS-1$ //$NON-NLS-2$; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/TextChangingEvent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2011 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | import android.os.Parcelable; 13 | import android.os.Parcel; 14 | 15 | /** 16 | * This event is sent by the StyledTextContent implementor when a change 17 | * to the text is about to occur. 18 | * 19 | * @see Sample code and further information 20 | */ 21 | public class TextChangingEvent { 22 | /** 23 | * Start offset of the text that is going to be replaced 24 | */ 25 | public int start; 26 | /** 27 | * Text that is going to be inserted or empty string 28 | * if no text will be inserted 29 | */ 30 | public String newText; 31 | /** 32 | * Length of text that is going to be replaced 33 | */ 34 | public int replaceCharCount; 35 | /** 36 | * Length of text that is going to be inserted 37 | */ 38 | public int newCharCount; 39 | /** 40 | * Number of lines that are going to be replaced 41 | */ 42 | public int replaceLineCount; 43 | /** 44 | * Number of new lines that are going to be inserted 45 | */ 46 | public int newLineCount; 47 | 48 | static final long serialVersionUID = 3257290210114352439L; 49 | 50 | /** 51 | * Create the TextChangedEvent to be used by the StyledTextContent implementor. 52 | *

53 | * 54 | * @param source the object that will be sending the new TextChangingEvent, 55 | * cannot be null 56 | */ 57 | public TextChangingEvent() {} 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/TextMessages.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2007, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.MissingResourceException; 15 | import java.util.ResourceBundle; 16 | 17 | 18 | /** 19 | * Helper class to get NLSed messages. 20 | * 21 | * @since 3.4 22 | */ 23 | class TextMessages { 24 | private static final String BUNDLE_NAME= "org.eclipse.jface.text.TextMessages"; //$NON-NLS-1$ 25 | 26 | private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); 27 | 28 | private TextMessages() { 29 | } 30 | 31 | public static String getString(String key) { 32 | try { 33 | return RESOURCE_BUNDLE.getString(key); 34 | } catch (MissingResourceException e) { 35 | return '!' + key + '!'; 36 | } 37 | } 38 | 39 | public static String getFormattedString(String key, Object arg) { 40 | return getFormattedString(key, new Object[] { arg }); 41 | } 42 | 43 | public static String getFormattedString(String key, Object[] args) { 44 | return MessageFormat.format(getString(key), args); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/TextMessages.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2008 IBM Corporation and others. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v1.0 5 | # which accompanies this distribution, and is available at 6 | # http://www.eclipse.org/legal/epl-v10.html 7 | # 8 | # Contributors: 9 | # IBM Corporation - initial API and implementation 10 | ############################################################################### 11 | 12 | FindReplaceDocumentAdapter.illegalControlEscape= Illegal control escape sequence {0} 13 | FindReplaceDocumentAdapter.illegalHexEscape= Illegal hexadecimal escape sequence {0} 14 | FindReplaceDocumentAdapter.illegalLinebreak=Illegal position for \\R 15 | FindReplaceDocumentAdapter.illegalUnicodeEscape= Illegal Unicode escape sequence {0} 16 | FindReplaceDocumentAdapter.incompatibleLineDelimiter= Incompatible line delimiter 17 | FindReplaceDocumentAdapter.patternTooComplex=Find pattern too complex 18 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/jface/text/TypedRegion.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.jface.text; 12 | 13 | 14 | /** 15 | * Default implementation of {@link org.eclipse.jface.text.ITypedRegion}. A 16 | * TypedRegion is a value object. 17 | */ 18 | public class TypedRegion extends Region implements ITypedRegion { 19 | 20 | /** The region's type */ 21 | private String fType; 22 | 23 | /** 24 | * Creates a typed region based on the given specification. 25 | * 26 | * @param offset the region's offset 27 | * @param length the region's length 28 | * @param type the region's type 29 | */ 30 | public TypedRegion(int offset, int length, String type) { 31 | super(offset, length); 32 | fType= type; 33 | } 34 | 35 | @Override 36 | public String getType() { 37 | return fType; 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (o instanceof TypedRegion) { 43 | TypedRegion r= (TypedRegion) o; 44 | return super.equals(r) && ((fType == null && r.getType() == null) || fType.equals(r.getType())); 45 | } 46 | return false; 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | int type= fType == null ? 0 : fType.hashCode(); 52 | return super.hashCode() | type; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return fType + " - " + super.toString(); //$NON-NLS-1$ 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/DeleteEdit.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.edits; 12 | 13 | import org.eclipse.jface.text.BadLocationException; 14 | import org.eclipse.jface.text.IDocument; 15 | 16 | /** 17 | * Text edit to delete a range in a document. 18 | *

19 | * A delete edit is equivalent to ReplaceEdit( 20 | * offset, length, ""). 21 | * 22 | * @since 3.0 23 | */ 24 | public final class DeleteEdit extends TextEdit { 25 | 26 | /** 27 | * Constructs a new delete edit. 28 | * 29 | * @param offset the offset of the range to replace 30 | * @param length the length of the range to replace 31 | */ 32 | public DeleteEdit(int offset, int length) { 33 | super(offset, length); 34 | } 35 | 36 | /* 37 | * Copy constructor 38 | */ 39 | private DeleteEdit(DeleteEdit other) { 40 | super(other); 41 | } 42 | 43 | /* 44 | * @see TextEdit#doCopy 45 | */ 46 | @Override 47 | protected TextEdit doCopy() { 48 | return new DeleteEdit(this); 49 | } 50 | 51 | /* 52 | * @see TextEdit#accept0 53 | */ 54 | @Override 55 | protected void accept0(TextEditVisitor visitor) { 56 | boolean visitChildren= visitor.visit(this); 57 | if (visitChildren) { 58 | acceptChildren(visitor); 59 | } 60 | } 61 | 62 | /* 63 | * @see TextEdit#performDocumentUpdating 64 | */ 65 | @Override 66 | int performDocumentUpdating(IDocument document) throws BadLocationException { 67 | document.replace(getOffset(), getLength(), ""); //$NON-NLS-1$ 68 | fDelta= -getLength(); 69 | return fDelta; 70 | } 71 | 72 | /* 73 | * @see TextEdit#deleteChildren 74 | */ 75 | @Override 76 | boolean deleteChildren() { 77 | return true; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/ISourceModifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2005 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.edits; 12 | 13 | /** 14 | * A source modifier can be used to modify the source of 15 | * a move or copy edit before it gets inserted at the target 16 | * position. This is useful if the text to be copied has to 17 | * be modified before it is inserted without changing the 18 | * original source. 19 | * 20 | * @since 3.0 21 | */ 22 | public interface ISourceModifier { 23 | /** 24 | * Returns the modification to be done to the passed 25 | * string in form of replace edits. The set of returned 26 | * replace edits must modify disjoint text regions. 27 | * Violating this requirement will result in a 28 | * BadLocationException while executing the 29 | * associated move or copy edit. 30 | *

31 | * The caller of this method is responsible to apply 32 | * the returned edits to the passed source. 33 | * 34 | * @param source the source to be copied or moved 35 | * @return an array of ReplaceEdits 36 | * describing the modifications. 37 | */ 38 | public ReplaceEdit[] getModifications(String source); 39 | 40 | /** 41 | * Creates a copy of this source modifier object. The copy will 42 | * be used in a different text edit object. So it should be 43 | * created in a way that is doesn't conflict with other text edits 44 | * referring to this source modifier. 45 | * 46 | * @return the copy of the source modifier 47 | */ 48 | public ISourceModifier copy(); 49 | } 50 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/MalformedTreeException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.edits; 12 | 13 | /** 14 | * Thrown to indicate that an edit got added to a parent edit 15 | * but the child edit somehow conflicts with the parent or 16 | * one of it siblings. 17 | *

18 | * This class is not intended to be serialized. 19 | *

20 | * 21 | * @see TextEdit#addChild(TextEdit) 22 | * @see TextEdit#addChildren(TextEdit[]) 23 | * 24 | * @since 3.0 25 | */ 26 | public class MalformedTreeException extends RuntimeException { 27 | 28 | // Not intended to be serialized 29 | private static final long serialVersionUID= 1L; 30 | 31 | private TextEdit fParent; 32 | private TextEdit fChild; 33 | 34 | /** 35 | * Constructs a new malformed tree exception. 36 | * 37 | * @param parent the parent edit 38 | * @param child the child edit 39 | * @param message the detail message 40 | */ 41 | public MalformedTreeException(TextEdit parent, TextEdit child, String message) { 42 | super(message); 43 | fParent= parent; 44 | fChild= child; 45 | } 46 | 47 | /** 48 | * Returns the parent edit that caused the exception. 49 | * 50 | * @return the parent edit 51 | */ 52 | public TextEdit getParent() { 53 | return fParent; 54 | } 55 | 56 | /** 57 | * Returns the child edit that caused the exception. 58 | * 59 | * @return the child edit 60 | */ 61 | public TextEdit getChild() { 62 | return fChild; 63 | } 64 | 65 | void setParent(TextEdit parent) { 66 | fParent= parent; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/Messages.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2000, 2005 IBM Corporation and others. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v1.0 5 | # which accompanies this distribution, and is available at 6 | # http://www.eclipse.org/legal/epl-v10.html 7 | # 8 | # Contributors: 9 | # IBM Corporation - initial API and implementation 10 | ############################################################################### 11 | 12 | TextEdit.range_outside= Range of child edit lies outside of parent edit 13 | TextEdit.overlapping= Overlapping text edits 14 | TextEdit.deleted_edit= Cannot add deleted edit 15 | 16 | CopySourceEdit.no_target= No target edit provided. 17 | CopySourceEdit.different_source= Target edit has different source edit. 18 | CopySourceEdit.different_tree= The source and target edits belong to a different text edit tree. 19 | 20 | CopyTargetEdit.no_source= No source edit provided. 21 | CopyTargetEdit.different_target= Source edit has different target edit. 22 | CopyTargetEdit.wrong_parent=Source edit must not be the parent of the target. 23 | 24 | MoveSourceEdit.no_target= No target edit provided. 25 | MoveSourceEdit.different_source= Target edit has different source edit. 26 | MoveSourceEdit.different_tree= The source and target edits belong to a different text edit tree. 27 | 28 | MoveTargetEdit.no_source= No source edit provided. 29 | MoveTargetEdit.different_target= Source edit has different target edit. 30 | MoveTargetEdit.wrong_parent=Source edit must not be the parent of the target. 31 | 32 | TextEditProcessor.invalid_length=End position lies outside document range 33 | 34 | UndoEdit.no_children=Cannot add children to an undo edit 35 | UndoEdit.can_not_be_added=Cannot add an undo edit to another edit 36 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/RangeMarker.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.edits; 12 | 13 | import org.eclipse.jface.text.BadLocationException; 14 | import org.eclipse.jface.text.IDocument; 15 | 16 | /** 17 | * A range marker can be used to track positions when executing 18 | * text edits. 19 | * 20 | * @since 3.0 21 | */ 22 | public final class RangeMarker extends TextEdit { 23 | 24 | /** 25 | * Creates a new range marker for the given offset and length. 26 | * 27 | * @param offset the marker's offset 28 | * @param length the marker's length 29 | */ 30 | public RangeMarker(int offset, int length) { 31 | super(offset, length); 32 | } 33 | 34 | /* 35 | * Copy constructor 36 | */ 37 | private RangeMarker(RangeMarker other) { 38 | super(other); 39 | } 40 | 41 | /* 42 | * @see TextEdit#copy 43 | */ 44 | @Override 45 | protected TextEdit doCopy() { 46 | return new RangeMarker(this); 47 | } 48 | 49 | /* 50 | * @see TextEdit#accept0 51 | */ 52 | @Override 53 | protected void accept0(TextEditVisitor visitor) { 54 | boolean visitChildren= visitor.visit(this); 55 | if (visitChildren) { 56 | acceptChildren(visitor); 57 | } 58 | } 59 | 60 | /* 61 | * @see TextEdit#performDocumentUpdating 62 | */ 63 | @Override 64 | int performDocumentUpdating(IDocument document) throws BadLocationException { 65 | fDelta= 0; 66 | return fDelta; 67 | } 68 | 69 | /* 70 | * @see TextEdit#deleteChildren 71 | */ 72 | @Override 73 | boolean deleteChildren() { 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/edits/TextEditMessages.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.edits; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.MissingResourceException; 15 | import java.util.ResourceBundle; 16 | 17 | class TextEditMessages { 18 | 19 | private static final String BUNDLE_NAME= "org.eclipse.text.edits.Messages"; //$NON-NLS-1$ 20 | 21 | private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); 22 | 23 | private TextEditMessages() { 24 | } 25 | 26 | public static String getString(String key) { 27 | try { 28 | return RESOURCE_BUNDLE.getString(key); 29 | } catch (MissingResourceException e) { 30 | return '!' + key + '!'; 31 | } 32 | } 33 | 34 | public static String getFormattedString(String key, Object arg) { 35 | return getFormattedString(key, new Object[] { arg }); 36 | } 37 | 38 | public static String getFormattedString(String key, Object[] args) { 39 | return MessageFormat.format(getString(key), args); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/undo/IDocumentUndoListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2006, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.undo; 12 | 13 | 14 | /** 15 | * This interface is used to listen to notifications from a DocumentUndoManager. 16 | * The supplied DocumentUndoEvent describes the particular notification. 17 | *

18 | * Document undo listeners must be prepared to receive notifications from a 19 | * background thread. Any UI access occurring inside the implementation must be 20 | * properly synchronized using the techniques specified by the client's widget 21 | * library.

22 | *

23 | * Clients may implement this interface. 24 | *

25 | * 26 | * @since 3.2 27 | */ 28 | public interface IDocumentUndoListener { 29 | 30 | /** 31 | * The document is involved in an undo-related change. Notify listeners 32 | * with an event describing the change. 33 | * 34 | * @param event the document undo event that describes the particular notification 35 | */ 36 | void documentUndoNotification(DocumentUndoEvent event); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/undo/UndoMessages.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2006, 2008 IBM Corporation and others. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Corporation - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.text.undo; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.ListResourceBundle; 15 | import java.util.MissingResourceException; 16 | import java.util.ResourceBundle; 17 | 18 | /** 19 | * Helper class to get NLSed messages. 20 | * 21 | * @since 3.2 22 | */ 23 | public final class UndoMessages extends ListResourceBundle { 24 | 25 | private static final String BUNDLE_NAME= "org.eclipse.text.undo.UndoMessages"; //$NON-NLS-1$ 26 | 27 | private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); 28 | 29 | public static String getString1(String key) { 30 | try { 31 | return RESOURCE_BUNDLE.getString(key); 32 | } catch (MissingResourceException e) { 33 | return '!' + key + '!'; 34 | } 35 | } 36 | 37 | public static String getFormattedString(String key, Object arg) { 38 | return getFormattedString(key, new Object[] { arg }); 39 | } 40 | 41 | public static String getFormattedString(String key, Object[] args) { 42 | return MessageFormat.format(getString1(key), args); 43 | } 44 | 45 | @Override 46 | protected Object[][] getContents() { 47 | return contents; 48 | } 49 | private static Object[][] contents = { 50 | {"DocumentUndoManager.operationLabel", "Typing"} 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /dom/src/main/java/org/eclipse/text/undo/UndoMessages.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2006 IBM Corporation and others. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v1.0 5 | # which accompanies this distribution, and is available at 6 | # http://www.eclipse.org/legal/epl-v10.html 7 | # 8 | # Contributors: 9 | # IBM Corporation - initial API and implementation 10 | ############################################################################### 11 | 12 | DocumentUndoManager.operationLabel= Typing 13 | -------------------------------------------------------------------------------- /dom/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | dom 3 | 4 | -------------------------------------------------------------------------------- /dom/src/test/java/org/eclipse/jdt/core/dom/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.jdt.core.dom; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /formatter/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /formatter/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | consumerProguardFiles 'consumer-rules.pro' 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | 30 | api project(':dom') 31 | 32 | } 33 | -------------------------------------------------------------------------------- /formatter/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/formatter/consumer-rules.pro -------------------------------------------------------------------------------- /formatter/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /formatter/src/androidTest/java/org/eclipse/jdt/core/formatter/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.jdt.core.formatter; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("org.eclipse.jdt.core.formatter.test", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /formatter/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /formatter/src/main/java/org/eclipse/jdt/core/formatter/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Package-level Javadoc 7 | 8 | 9 | The code formatter is the set of classes that are used to format Java code. 10 | 11 |

12 | Package Specification

13 | 14 |

This package contains classes to format Java code. 15 | The principal classes are {@link org.eclipse.jdt.core.formatter.CodeFormatter CodeFormatter} and 16 | {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants DefaultCodeFormatterConstants}. 17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /formatter/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | formatter 3 | 4 | -------------------------------------------------------------------------------- /formatter/src/test/java/org/eclipse/jdt/core/formatter/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.jdt.core.formatter; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | # AndroidX package structure to make it clearer which packages are bundled with the 20 | # Android operating system, and which are packaged with your app's APK 21 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 22 | android.useAndroidX=true 23 | # Automatically convert third-party libraries to use AndroidX 24 | android.enableJetifier=true 25 | 26 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4455jkjh/TextView/95635f0cfea2b8e32d1226e5e8527f8ea590b5bb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 07 18:38:19 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':dom', ':formatter' 2 | rootProject.name='TextView' 3 | --------------------------------------------------------------------------------