idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
33,500 | public void increment ( int level ) { assert level >= 1 ; if ( this . numbers . size ( ) < level ) { do { this . numbers . addLast ( 0 ) ; } while ( this . numbers . size ( ) < level ) ; } else if ( this . numbers . size ( ) > level ) { do { this . numbers . removeLast ( ) ; } while ( this . numbers . size ( ) > level ) ; } assert this . numbers . size ( ) == level ; final int previousSection = this . numbers . removeLast ( ) ; this . numbers . addLast ( previousSection + 1 ) ; } | Change this version number by incrementing the number for the given level . | 132 | 14 |
33,501 | @ Fix ( "*" ) public void fixSuppressWarnings ( Issue issue , IssueResolutionAcceptor acceptor ) { if ( isIgnorable ( issue . getCode ( ) ) ) { SuppressWarningsAddModification . accept ( this , issue , acceptor ) ; } } | Add the fixes with suppress - warning annotations . | 64 | 9 |
33,502 | public List < JvmOperation > getJvmOperationsFromURIs ( XtendTypeDeclaration container , String ... operationUris ) { // Collect the JvmOperation prior to any modification for ensuring that // URI are pointing the JvmOperations. final List < JvmOperation > operations = new ArrayList <> ( ) ; final ResourceSet resourceSet = container . eResource ( ) . getResourceSet ( ) ; for ( final String operationUriAsString : operationUris ) { final URI operationURI = URI . createURI ( operationUriAsString ) ; final EObject overridden = resourceSet . getEObject ( operationURI , true ) ; if ( overridden instanceof JvmOperation ) { final JvmOperation operation = ( JvmOperation ) overridden ; if ( this . annotationFinder . findAnnotation ( operation , DefaultValueUse . class ) == null ) { operations . add ( operation ) ; } } } return operations ; } | Replies the JVM operations that correspond to the given URIs . | 205 | 14 |
33,503 | public boolean removeToPreviousSeparator ( Issue issue , IXtextDocument document , String separator ) throws BadLocationException { return removeToPreviousSeparator ( issue . getOffset ( ) , issue . getLength ( ) , document , separator ) ; } | Remove the element related to the issue and the whitespaces before the element until the given separator . | 55 | 20 |
33,504 | public boolean removeToPreviousSeparator ( int offset , int length , IXtextDocument document , String separator ) throws BadLocationException { // Skip spaces before the identifier until the separator int index = offset - 1 ; char c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } // Test if it previous non-space character is the separator final boolean foundSeparator = document . getChar ( index ) == separator . charAt ( 0 ) ; if ( foundSeparator ) { index -- ; c = document . getChar ( index ) ; // Skip the previous spaces while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } final int delta = offset - index - 1 ; document . replace ( index + 1 , length + delta , "" ) ; //$NON-NLS-1$ } return foundSeparator ; } | Remove the portion of text and the whitespaces before the text until the given separator . | 217 | 18 |
33,505 | public int getImportInsertOffset ( SarlScript script ) { final ICompositeNode node = NodeModelUtils . findActualNodeFor ( script . getImportSection ( ) ) ; if ( node == null ) { final List < INode > children = NodeModelUtils . findNodesForFeature ( script , XtendPackage . eINSTANCE . getXtendFile_Package ( ) ) ; if ( children . isEmpty ( ) ) { return 0 ; } return children . get ( 0 ) . getEndOffset ( ) ; } return node . getEndOffset ( ) ; } | Replies the index where import declaration could be inserted into the given container . | 128 | 15 |
33,506 | public boolean removeToNextSeparator ( Issue issue , IXtextDocument document , String separator ) throws BadLocationException { // Skip spaces after the identifier until the separator int index = issue . getOffset ( ) + issue . getLength ( ) ; char c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index ++ ; c = document . getChar ( index ) ; } // Test if it next non-space character is the separator final boolean foundSeparator = document . getChar ( index ) == separator . charAt ( 0 ) ; if ( foundSeparator ) { index ++ ; c = document . getChar ( index ) ; // Skip the previous spaces while ( Character . isWhitespace ( c ) ) { index ++ ; c = document . getChar ( index ) ; } final int newLength = index - issue . getOffset ( ) ; document . replace ( issue . getOffset ( ) , newLength , "" ) ; //$NON-NLS-1$ } return foundSeparator ; } | Remove the element related to the issue and the whitespaces after the element until the given separator . | 230 | 20 |
33,507 | public boolean removeToPreviousKeyword ( Issue issue , IXtextDocument document , String keyword1 , String ... otherKeywords ) throws BadLocationException { // Skip spaces before the element int index = issue . getOffset ( ) - 1 ; char c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } // Skip non-spaces before the identifier final StringBuffer kw = new StringBuffer ( ) ; while ( ! Character . isWhitespace ( c ) ) { kw . insert ( 0 , c ) ; index -- ; c = document . getChar ( index ) ; } if ( kw . toString ( ) . equals ( keyword1 ) || Arrays . contains ( otherKeywords , kw . toString ( ) ) ) { // Skip spaces before the previous keyword while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } final int delta = issue . getOffset ( ) - index - 1 ; document . replace ( index + 1 , issue . getLength ( ) + delta , "" ) ; //$NON-NLS-1$ return true ; } return false ; } | Remove the element related to the issue and the whitespaces before the element until one of the given keywords is encountered . | 268 | 23 |
33,508 | public boolean removeBetweenSeparators ( Issue issue , IXtextDocument document , String beginSeparator , String endSeparator ) throws BadLocationException { int offset = issue . getOffset ( ) ; int length = issue . getLength ( ) ; // Skip spaces before the identifier until the separator int index = offset - 1 ; char c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } // Test if it previous non-space character is the separator boolean foundSeparator = document . getChar ( index ) == beginSeparator . charAt ( 0 ) ; if ( foundSeparator ) { index -- ; c = document . getChar ( index ) ; // Skip the previous spaces while ( Character . isWhitespace ( c ) ) { index -- ; c = document . getChar ( index ) ; } length = length + ( offset - index - 1 ) ; offset = index + 1 ; // Skip spaces after the identifier until the separator index = offset + length ; c = document . getChar ( index ) ; while ( Character . isWhitespace ( c ) ) { index ++ ; c = document . getChar ( index ) ; } // Test if it next non-space character is the separator foundSeparator = document . getChar ( index ) == endSeparator . charAt ( 0 ) ; if ( foundSeparator ) { index ++ ; length = index - offset ; document . replace ( offset , length , "" ) ; //$NON-NLS-1$ } } return foundSeparator ; } | Remove the element related to the issue and the whitespaces before the element until the begin separator and the whitespaces after the element until the end separator . | 354 | 32 |
33,509 | public int getInsertOffset ( XtendTypeDeclaration container ) { if ( container . getMembers ( ) . isEmpty ( ) ) { final ICompositeNode node = NodeModelUtils . findActualNodeFor ( container ) ; final ILeafNode openingBraceNode = IterableExtensions . findFirst ( node . getLeafNodes ( ) , lnode -> "{" . equals ( lnode . getText ( ) ) ) ; //$NON-NLS-1$ if ( openingBraceNode != null ) { return openingBraceNode . getOffset ( ) + 1 ; } return node . getEndOffset ( ) ; } final EObject lastFeature = IterableExtensions . last ( container . getMembers ( ) ) ; final ICompositeNode node = NodeModelUtils . findActualNodeFor ( lastFeature ) ; return node . getEndOffset ( ) ; } | Replies the index where elements could be inserted into the given container . | 196 | 14 |
33,510 | public int getSpaceSize ( IXtextDocument document , int offset ) throws BadLocationException { int size = 0 ; char c = document . getChar ( offset + size ) ; while ( Character . isWhitespace ( c ) ) { size ++ ; c = document . getChar ( offset + size ) ; } return size ; } | Replies the size of a sequence of whitespaces . | 70 | 11 |
33,511 | public int getOffsetForPattern ( IXtextDocument document , int startOffset , String pattern ) { final Pattern compiledPattern = Pattern . compile ( pattern ) ; final Matcher matcher = compiledPattern . matcher ( document . get ( ) ) ; if ( matcher . find ( startOffset ) ) { final int end = matcher . end ( ) ; return end ; } return - 1 ; } | Replies the offset that corresponds to the given regular expression pattern . | 83 | 13 |
33,512 | public QualifiedName qualifiedName ( String name ) { if ( ! com . google . common . base . Strings . isNullOrEmpty ( name ) ) { final List < String > segments = Strings . split ( name , "." ) ; //$NON-NLS-1$ return QualifiedName . create ( segments ) ; } return QualifiedName . create ( ) ; } | Replies the qualified name for the given name . | 83 | 10 |
33,513 | public void removeExecutableFeature ( EObject element , IModificationContext context ) throws BadLocationException { final ICompositeNode node ; final SarlAction action = EcoreUtil2 . getContainerOfType ( element , SarlAction . class ) ; if ( action == null ) { final XtendMember feature = EcoreUtil2 . getContainerOfType ( element , XtendMember . class ) ; node = NodeModelUtils . findActualNodeFor ( feature ) ; } else { node = NodeModelUtils . findActualNodeFor ( action ) ; } if ( node != null ) { remove ( context . getXtextDocument ( ) , node ) ; } } | Remove the exectuable feature . | 150 | 7 |
33,514 | @ Fix ( IssueCodes . DUPLICATE_TYPE_NAME ) public void fixDuplicateTopElements ( Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Duplicate type . | 53 | 7 |
33,515 | @ Fix ( IssueCodes . DUPLICATE_FIELD ) public void fixDuplicateAttribute ( Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Duplicate field . | 49 | 7 |
33,516 | @ Fix ( IssueCodes . DUPLICATE_METHOD ) public void fixDuplicateMethod ( Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Duplicate method . | 49 | 7 |
33,517 | @ Fix ( IssueCodes . INVALID_MEMBER_NAME ) public void fixMemberName ( final Issue issue , IssueResolutionAcceptor acceptor ) { MemberRenameModification . accept ( this , issue , acceptor ) ; MemberRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Invalid member name . | 67 | 7 |
33,518 | @ Fix ( io . sarl . lang . validation . IssueCodes . REDUNDANT_INTERFACE_IMPLEMENTATION ) public void fixRedundantInterface ( final Issue issue , IssueResolutionAcceptor acceptor ) { ImplementedTypeRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Redundant interface implementation . | 69 | 9 |
33,519 | @ Fix ( org . eclipse . xtext . xbase . validation . IssueCodes . VARIABLE_NAME_SHADOWING ) public void fixVariableNameShadowing ( final Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor ) ; MemberRenameModification . accept ( this , issue , acceptor ) ; } | Quick fix for Variable name shadowing . | 84 | 8 |
33,520 | @ Fix ( IssueCodes . OVERRIDDEN_FINAL ) public void fixOverriddenFinal ( Issue issue , IssueResolutionAcceptor acceptor ) { final MultiModification modifications = new MultiModification ( this , issue , acceptor , Messages . SARLQuickfixProvider_0 , Messages . SARLQuickfixProvider_1 ) ; modifications . bind ( XtendTypeDeclaration . class , SuperTypeRemoveModification . class ) ; modifications . bind ( XtendMember . class , MemberRemoveModification . class ) ; } | Quick fix for Override final operation . | 115 | 8 |
33,521 | @ Fix ( io . sarl . lang . validation . IssueCodes . DISCOURAGED_BOOLEAN_EXPRESSION ) public void fixDiscouragedBooleanExpression ( final Issue issue , IssueResolutionAcceptor acceptor ) { BehaviorUnitGuardRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Discouraged boolean expression . | 73 | 9 |
33,522 | @ Fix ( io . sarl . lang . validation . IssueCodes . UNREACHABLE_BEHAVIOR_UNIT ) public void fixUnreachableBehaviorUnit ( Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Unreachable behavior unit . | 67 | 9 |
33,523 | @ Fix ( io . sarl . lang . validation . IssueCodes . INVALID_CAPACITY_TYPE ) public void fixInvalidCapacityType ( final Issue issue , IssueResolutionAcceptor acceptor ) { CapacityReferenceRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Invalid capacity type . | 64 | 7 |
33,524 | @ Fix ( io . sarl . lang . validation . IssueCodes . INVALID_FIRING_EVENT_TYPE ) public void fixInvalidFiringEventType ( final Issue issue , IssueResolutionAcceptor acceptor ) { FiredEventRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Invalid firing event type . | 67 | 8 |
33,525 | @ Fix ( io . sarl . lang . validation . IssueCodes . INVALID_IMPLEMENTED_TYPE ) public void fixInvalidImplementedType ( final Issue issue , IssueResolutionAcceptor acceptor ) { ImplementedTypeRemoveModification . accept ( this , issue , acceptor , RemovalType . OTHER ) ; } | Quick fix for Invalid implemented type . | 73 | 7 |
33,526 | @ Fix ( io . sarl . lang . validation . IssueCodes . INVALID_EXTENDED_TYPE ) public void fixInvalidExtendedType ( final Issue issue , IssueResolutionAcceptor acceptor ) { ExtendedTypeRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Invalid extended type . | 63 | 7 |
33,527 | @ Fix ( IssueCodes . CYCLIC_INHERITANCE ) public void fixCyclicInheritance ( final Issue issue , IssueResolutionAcceptor acceptor ) { ExtendedTypeRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Cyclic hierarchy . | 56 | 7 |
33,528 | @ Fix ( IssueCodes . INTERFACE_EXPECTED ) public void fixInteraceExpected ( final Issue issue , IssueResolutionAcceptor acceptor ) { ExtendedTypeRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Interface expected . | 52 | 6 |
33,529 | @ Fix ( IssueCodes . CLASS_EXPECTED ) public void fixClassExpected ( final Issue issue , IssueResolutionAcceptor acceptor ) { ExtendedTypeRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Class expected . | 50 | 6 |
33,530 | @ Fix ( io . sarl . lang . validation . IssueCodes . DISCOURAGED_CAPACITY_DEFINITION ) public void fixDiscouragedCapacityDefinition ( Issue issue , IssueResolutionAcceptor acceptor ) { MemberRemoveModification . accept ( this , issue , acceptor , SarlCapacity . class ) ; ActionAddModification . accept ( this , issue , acceptor ) ; } | Quick fix for Discouraged capacity definition . | 90 | 9 |
33,531 | @ Fix ( org . eclipse . xtext . xbase . validation . IssueCodes . INCOMPATIBLE_RETURN_TYPE ) public void fixIncompatibleReturnType ( final Issue issue , IssueResolutionAcceptor acceptor ) { ReturnTypeReplaceModification . accept ( this , issue , acceptor ) ; } | Quick fix for Incompatible return type . | 69 | 8 |
33,532 | @ Fix ( io . sarl . lang . validation . IssueCodes . RETURN_TYPE_SPECIFICATION_IS_RECOMMENDED ) public void fixReturnTypeRecommended ( final Issue issue , IssueResolutionAcceptor acceptor ) { ReturnTypeAddModification . accept ( this , issue , acceptor ) ; } | Quick fix for Return type is recommended . | 69 | 8 |
33,533 | @ Fix ( io . sarl . lang . validation . IssueCodes . UNUSED_AGENT_CAPACITY ) public void fixUnusedAgentCapacity ( final Issue issue , IssueResolutionAcceptor acceptor ) { CapacityReferenceRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Unused agent capacity . | 66 | 8 |
33,534 | @ Fix ( io . sarl . lang . validation . IssueCodes . REDUNDANT_CAPACITY_USE ) public void fixRedundantAgentCapacityUse ( final Issue issue , IssueResolutionAcceptor acceptor ) { CapacityReferenceRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for Redundant capacity use . | 68 | 9 |
33,535 | @ Fix ( SyntaxIssueCodes . USED_RESERVED_KEYWORD ) public void fixNoViableAlternativeAtKeyword ( final Issue issue , IssueResolutionAcceptor acceptor ) { ProtectKeywordModification . accept ( this , issue , acceptor ) ; } | Quick fix for the no viable alternative at an input that is a SARL keyword . | 62 | 17 |
33,536 | @ Fix ( io . sarl . lang . validation . IssueCodes . USED_RESERVED_SARL_ANNOTATION ) public void fixDiscouragedAnnotationUse ( final Issue issue , IssueResolutionAcceptor acceptor ) { AnnotationRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for the discouraged annotation uses . | 72 | 8 |
33,537 | @ Fix ( io . sarl . lang . validation . IssueCodes . MANUAL_INLINE_DEFINITION ) public void fixManualInlineDefinition ( final Issue issue , IssueResolutionAcceptor acceptor ) { AnnotationRemoveModification . accept ( this , issue , acceptor ) ; } | Quick fix for the manual definition of inline statements . | 65 | 10 |
33,538 | public IDialogSettings getDialogSettingsSection ( String name ) { final IDialogSettings dialogSettings = getDialogSettings ( ) ; IDialogSettings section = dialogSettings . getSection ( name ) ; if ( section == null ) { section = dialogSettings . addNewSection ( name ) ; } return section ; } | Returns a section in the SARL Eclipse plugin s dialog settings . If the section doesn t exist yet it is created . | 67 | 24 |
33,539 | public PyGeneratorConfiguration install ( ResourceSet resourceSet , PyGeneratorConfiguration config ) { assert config != null ; PyGeneratorConfigAdapter adapter = PyGeneratorConfigAdapter . findInEmfObject ( resourceSet ) ; if ( adapter == null ) { adapter = new PyGeneratorConfigAdapter ( ) ; } adapter . attachToEmfObject ( resourceSet ) ; return adapter . getLanguage2GeneratorConfig ( ) . put ( this . languageId , config ) ; } | Install the given configuration into the context . | 101 | 8 |
33,540 | protected void generatePythonSetup ( IStyleAppendable it , String basename ) { it . appendNl ( "# -*- coding: {0} -*-" , getCodeConfig ( ) . getEncoding ( ) . toLowerCase ( ) ) ; //$NON-NLS-1$ it . appendHeader ( ) ; it . newLine ( ) ; it . append ( "from setuptools import setup" ) ; //$NON-NLS-1$ it . newLine ( ) . newLine ( ) ; it . append ( "setup (" ) ; //$NON-NLS-1$ it . increaseIndentation ( ) . newLine ( ) ; it . append ( "name='" ) . append ( basename ) . append ( "lexer'," ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( "version='" ) . append ( getLanguageVersion ( ) ) . append ( "'," ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( "packages=['" ) . append ( basename ) . append ( "lexer']," ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( "entry_points =" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\"\"\"" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "[pygments.lexers]" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "sarllexer = " ) . append ( basename ) . append ( "lexer." ) . append ( basename ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . append ( ":SarlLexer" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "\"\"\"," ) ; //$NON-NLS-1$ it . decreaseIndentation ( ) . newLine ( ) ; it . append ( ")" ) ; //$NON-NLS-1$ it . newLine ( ) ; } | Create the content of the setup . py file . | 537 | 10 |
33,541 | public JvmParameterizedTypeReference newTypeRef ( Notifier context , String typeName ) { return this . builder . newTypeRef ( context , typeName ) ; } | Find the reference to the type with the given name . | 36 | 11 |
33,542 | protected LightweightTypeReference getLightweightType ( XExpression expr ) { final IResolvedTypes resolvedTypes = getResolvedTypes ( expr ) ; final LightweightTypeReference expressionType = resolvedTypes . getActualType ( expr ) ; if ( expr instanceof AnonymousClass ) { final List < LightweightTypeReference > superTypes = expressionType . getSuperTypes ( ) ; if ( superTypes . size ( ) == 1 ) { return superTypes . get ( 0 ) ; } } return expressionType ; } | Replies the inferred type for the given expression . | 108 | 10 |
33,543 | private void createImplicitVariableType ( XtextResource resource , IAcceptor < ? super ICodeMining > acceptor ) { createImplicitVarValType ( resource , acceptor , XtendVariableDeclaration . class , it -> it . getType ( ) , it -> { LightweightTypeReference type = getLightweightType ( it . getRight ( ) ) ; if ( type . isAny ( ) ) { type = getTypeForVariableDeclaration ( it . getRight ( ) ) ; } return type . getSimpleName ( ) ; } , it -> it . getRight ( ) , ( ) -> this . grammar . getXVariableDeclarationAccess ( ) . getRightAssignment_3_1 ( ) ) ; } | Add an annotation when the variable s type is implicit and inferred by the SARL compiler . | 157 | 18 |
33,544 | private void createImplicitFieldType ( XtextResource resource , IAcceptor < ? super ICodeMining > acceptor ) { createImplicitVarValType ( resource , acceptor , XtendField . class , it -> it . getType ( ) , it -> { final JvmField inferredField = ( JvmField ) this . jvmModelAssocitions . getPrimaryJvmElement ( it ) ; if ( inferredField == null || inferredField . getType ( ) == null || inferredField . getType ( ) . eIsProxy ( ) ) { return null ; } return inferredField . getType ( ) . getSimpleName ( ) ; } , null , ( ) -> this . grammar . getAOPMemberAccess ( ) . getInitialValueAssignment_2_3_3_1 ( ) ) ; } | Add an annotation when the field s type is implicit and inferred by the SARL compiler . | 177 | 18 |
33,545 | @ SuppressWarnings ( "checkstyle:npathcomplexity" ) private void createImplicitActionReturnType ( XtextResource resource , IAcceptor < ? super ICodeMining > acceptor ) { final List < XtendFunction > actions = EcoreUtil2 . eAllOfType ( resource . getContents ( ) . get ( 0 ) , XtendFunction . class ) ; for ( final XtendFunction action : actions ) { // inline annotation only for methods with no return type if ( action . getReturnType ( ) != null ) { continue ; } // get return type name from operation final JvmOperation inferredOperation = ( JvmOperation ) this . jvmModelAssocitions . getPrimaryJvmElement ( action ) ; if ( inferredOperation == null || inferredOperation . getReturnType ( ) == null ) { continue ; } // find document offset for inline annotationn final ICompositeNode node = NodeModelUtils . findActualNodeFor ( action ) ; final Keyword parenthesis = this . grammar . getAOPMemberAccess ( ) . getRightParenthesisKeyword_2_5_6_2 ( ) ; final Assignment fctname = this . grammar . getAOPMemberAccess ( ) . getNameAssignment_2_5_5 ( ) ; int offsetFctname = - 1 ; int offsetParenthesis = - 1 ; for ( Iterator < INode > it = node . getAsTreeIterable ( ) . iterator ( ) ; it . hasNext ( ) ; ) { final INode child = it . next ( ) ; if ( child != node ) { final EObject grammarElement = child . getGrammarElement ( ) ; if ( grammarElement instanceof RuleCall ) { if ( fctname . equals ( grammarElement . eContainer ( ) ) ) { offsetFctname = child . getTotalEndOffset ( ) ; } } else if ( parenthesis . equals ( grammarElement ) ) { offsetParenthesis = child . getTotalEndOffset ( ) ; break ; } } } int offset = - 1 ; if ( offsetParenthesis >= 0 ) { offset = offsetParenthesis ; } else if ( offsetFctname >= 0 ) { offset = offsetFctname ; } if ( offset >= 0 ) { final String returnType = inferredOperation . getReturnType ( ) . getSimpleName ( ) ; final String text = " " + this . keywords . getColonKeyword ( ) + " " + returnType ; //$NON-NLS-1$ //$NON-NLS-2$ acceptor . accept ( createNewLineContentCodeMining ( offset , text ) ) ; } } } | Add an annotation when the action s return type is implicit and inferred by the SARL compiler . | 574 | 19 |
33,546 | public Set < String > getPureKeywords ( ) { Set < String > kws = this . pureSarlKeywords == null ? null : this . pureSarlKeywords . get ( ) ; if ( kws == null ) { kws = new HashSet <> ( ) ; kws . add ( getAsKeyword ( ) ) ; kws . add ( getRequiresKeyword ( ) ) ; kws . add ( getWithKeyword ( ) ) ; kws . add ( getItKeyword ( ) ) ; kws . add ( getArtifactKeyword ( ) ) ; kws . add ( getAnnotationKeyword ( ) ) ; kws . add ( getSpaceKeyword ( ) ) ; kws . add ( getOnKeyword ( ) ) ; kws . add ( getCapacityKeyword ( ) ) ; kws . add ( getEventKeyword ( ) ) ; kws . add ( getVarKeyword ( ) ) ; kws . add ( getAgentKeyword ( ) ) ; kws . add ( getDispatchKeyword ( ) ) ; kws . add ( getUsesKeyword ( ) ) ; kws . add ( getSkillKeyword ( ) ) ; kws . add ( getDefKeyword ( ) ) ; kws . add ( getFiresKeyword ( ) ) ; kws . add ( getOverrideKeyword ( ) ) ; kws . add ( getIsStaticAssumeKeyword ( ) ) ; kws . add ( getBehaviorKeyword ( ) ) ; kws . add ( getExtensionExtensionKeyword ( ) ) ; kws . add ( getValKeyword ( ) ) ; kws . add ( getTypeofKeyword ( ) ) ; kws . add ( getOccurrenceKeyword ( ) ) ; this . pureSarlKeywords = new SoftReference <> ( kws ) ; } return Collections . unmodifiableSet ( kws ) ; } | Replies the pure SARL keywords . Pure SARL keywords are SARL keywords that are not Java keywords . | 420 | 22 |
33,547 | public String protectKeyword ( String text ) { if ( ! Strings . isEmpty ( text ) && isKeyword ( text ) ) { return "^" + text ; } return text ; } | Protect the given text if it is a keyword . | 42 | 10 |
33,548 | @ Check public void checkImportsMapping ( XImportDeclaration importDeclaration ) { final JvmDeclaredType type = importDeclaration . getImportedType ( ) ; doTypeMappingCheck ( importDeclaration , type , this . typeErrorHandler1 ) ; } | Check that import mapping are known . | 59 | 7 |
33,549 | public static void importMavenProject ( IWorkspaceRoot workspaceRoot , String projectName , boolean addSarlSpecificSourceFolders , IProgressMonitor monitor ) { // XXX: The m2e plugin seems to have an issue for creating a fresh project with the SARL plugin as an extension. // Solution: Create a simple project, and switch to a real SARL project. final WorkspaceJob bugFixJob = new WorkspaceJob ( "Creating Simple Maven project" ) { //$NON-NLS-1$ @ SuppressWarnings ( "synthetic-access" ) @ Override public IStatus runInWorkspace ( IProgressMonitor monitor ) throws CoreException { try { final SubMonitor submon = SubMonitor . convert ( monitor , 3 ) ; forceSimplePom ( workspaceRoot , projectName , submon . newChild ( 1 ) ) ; final AbstractProjectScanner < MavenProjectInfo > scanner = getProjectScanner ( workspaceRoot , projectName ) ; scanner . run ( submon . newChild ( 1 ) ) ; final ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration ( ) ; runFixedImportJob ( addSarlSpecificSourceFolders , scanner . getProjects ( ) , importConfiguration , null , submon . newChild ( 1 ) ) ; } catch ( Exception exception ) { return SARLMavenEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , exception ) ; } return Status . OK_STATUS ; } } ; bugFixJob . setRule ( MavenPlugin . getProjectConfigurationManager ( ) . getRule ( ) ) ; bugFixJob . schedule ( ) ; } | Create a fresh Maven project from existing files assuming a pom file exists . | 351 | 16 |
33,550 | static List < IMavenProjectImportResult > runFixedImportJob ( boolean addSarlSpecificSourceFolders , Collection < MavenProjectInfo > projectInfos , ProjectImportConfiguration importConfiguration , IProjectCreationListener projectCreationListener , IProgressMonitor monitor ) throws CoreException { final List < IMavenProjectImportResult > importResults = MavenPlugin . getProjectConfigurationManager ( ) . importProjects ( projectInfos , importConfiguration , projectCreationListener , monitor ) ; if ( addSarlSpecificSourceFolders ) { final SubMonitor submon = SubMonitor . convert ( monitor , importResults . size ( ) ) ; for ( final IMavenProjectImportResult importResult : importResults ) { SARLProjectConfigurator . configureSARLSourceFolders ( // Project to configure importResult . getProject ( ) , // Create folders true , // Monitor submon . newChild ( 1 ) ) ; final WorkspaceJob job = new WorkspaceJob ( "Creating Maven project" ) { //$NON-NLS-1$ @ SuppressWarnings ( "synthetic-access" ) @ Override public IStatus runInWorkspace ( IProgressMonitor monitor ) throws CoreException { try { runBugFix ( importResult . getProject ( ) , monitor ) ; } catch ( Exception exception ) { return SARLMavenEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , exception ) ; } return Status . OK_STATUS ; } } ; job . setRule ( MavenPlugin . getProjectConfigurationManager ( ) . getRule ( ) ) ; job . schedule ( ) ; } } return importResults ; } | Run the job that execute a fixed import of a Maven project . | 354 | 14 |
33,551 | static void forceSimplePom ( File projectDir , IProgressMonitor monitor ) throws IOException { final File pomFile = new File ( projectDir , POM_FILE ) ; if ( pomFile . exists ( ) ) { final SubMonitor submon = SubMonitor . convert ( monitor , 4 ) ; final File savedPomFile = new File ( projectDir , POM_BACKUP_FILE ) ; if ( savedPomFile . exists ( ) ) { savedPomFile . delete ( ) ; } submon . worked ( 1 ) ; Files . copy ( pomFile , savedPomFile ) ; submon . worked ( 1 ) ; final StringBuilder content = new StringBuilder ( ) ; try ( BufferedReader stream = new BufferedReader ( new FileReader ( pomFile ) ) ) { String line = stream . readLine ( ) ; while ( line != null ) { line = line . replaceAll ( "<extensions>\\s*true\\s*</extensions>" , "" ) ; //$NON-NLS-1$ //$NON-NLS-2$ content . append ( line ) . append ( "\n" ) ; //$NON-NLS-1$ line = stream . readLine ( ) ; } } submon . worked ( 1 ) ; Files . write ( content . toString ( ) . getBytes ( ) , pomFile ) ; submon . worked ( 1 ) ; } } | Force the pom file of a project to be simple . | 310 | 12 |
33,552 | public final Set < String > getBundleDependencies ( ) { final Set < String > bundles = new TreeSet <> ( ) ; updateBundleList ( bundles ) ; return bundles ; } | Replies the list of the symbolic names of the bundle dependencies . | 42 | 13 |
33,553 | @ SuppressWarnings ( "static-method" ) @ Pure @ Inline ( value = "$1.getCaller()" , imported = Capacities . class , constantExpression = true ) protected AgentTrait getCaller ( ) { return Capacities . getCaller ( ) ; } | Replies the caller of the capacity functions . | 66 | 9 |
33,554 | void unregisterUse ( ) { final int value = this . uses . decrementAndGet ( ) ; if ( value == 0 ) { uninstall ( UninstallationStage . PRE_DESTROY_EVENT ) ; uninstall ( UninstallationStage . POST_DESTROY_EVENT ) ; } } | Mark this skill as release by one user . | 65 | 9 |
33,555 | protected void generateIFormalParameterBuilder ( ) { final TypeReference builder = getFormalParameterBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of a " + getLanguageName ( ) //$NON-NLS-1$ + " formal parameter." ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public interface " ) ; //$NON-NLS-1$ it . append ( builder . getSimpleName ( ) ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateMembers ( true , false ) ) ; it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the formal parameter builder interface . | 328 | 8 |
33,556 | protected void generateFormalParameterAppender ( ) { final CodeElementExtractor . ElementDescription parameter = getCodeElementExtractor ( ) . getFormalParameter ( ) ; final String accessor = "get" //$NON-NLS-1$ + Strings . toFirstUpper ( parameter . getElementType ( ) . getSimpleName ( ) ) + "()" ; //$NON-NLS-1$ final TypeReference builderInterface = getFormalParameterBuilderInterface ( ) ; final TypeReference appender = getCodeElementExtractor ( ) . getElementAppenderImpl ( "FormalParameter" ) ; //$NON-NLS-1$ final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Appender of a " + getLanguageName ( ) //$NON-NLS-1$ + " formal parameter." ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public class " ) ; //$NON-NLS-1$ it . append ( appender . getSimpleName ( ) ) ; it . append ( " extends " ) ; //$NON-NLS-1$ it . append ( getCodeElementExtractor ( ) . getAbstractAppenderImpl ( ) ) ; it . append ( " implements " ) ; //$NON-NLS-1$ it . append ( builderInterface ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateAppenderMembers ( appender . getSimpleName ( ) , builderInterface , accessor ) ) ; it . append ( generateMembers ( false , true ) ) ; it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the formal parameter appender . | 544 | 8 |
33,557 | protected void fireContextCreated ( AgentContext context ) { final ContextRepositoryListener [ ] ilisteners = this . listeners . getListeners ( ContextRepositoryListener . class ) ; this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . StandardContextSpaceService_0 , context . getID ( ) ) ) ; for ( final ContextRepositoryListener listener : ilisteners ) { listener . contextCreated ( context ) ; } } | Notifies the listeners about a context creation . | 99 | 9 |
33,558 | protected void fireContextDestroyed ( AgentContext context ) { final ContextRepositoryListener [ ] ilisteners = this . listeners . getListeners ( ContextRepositoryListener . class ) ; this . logger . getKernelLogger ( ) . info ( MessageFormat . format ( Messages . StandardContextSpaceService_1 , context . getID ( ) ) ) ; for ( final ContextRepositoryListener listener : ilisteners ) { listener . contextDestroyed ( context ) ; } } | Notifies the listeners about a context destruction . | 101 | 9 |
33,559 | protected void removeDefaultSpaceDefinition ( SpaceID spaceID ) { AgentContext context = null ; synchronized ( mutex ( ) ) { context = this . contexts . remove ( spaceID . getContextID ( ) ) ; } if ( context != null ) { fireContextDestroyed ( context ) ; } } | Update the internal data structure when a default space was removed . | 63 | 12 |
33,560 | public void addRequirement ( String requirement ) { if ( ! Strings . isEmpty ( requirement ) ) { if ( this . requirements == null ) { this . requirements = new ArrayList <> ( ) ; } this . requirements . add ( requirement ) ; } } | Add a TeX requirement . | 56 | 6 |
33,561 | @ SuppressWarnings ( "static-method" ) protected boolean generateOptions ( IStyleAppendable it ) { it . appendNl ( "\\newif\\ifusesarlcolors\\usesarlcolorstrue" ) ; //$NON-NLS-1$ it . appendNl ( "\\DeclareOption{sarlcolors}{\\global\\usesarlcolorstrue}" ) ; //$NON-NLS-1$ it . appendNl ( "\\DeclareOption{nosarlcolors}{\\global\\usesarlcolorsfalse}" ) ; //$NON-NLS-1$ return true ; } | Generate the optional extensions . | 142 | 6 |
33,562 | @ Inject public void setKey ( @ Named ( NetworkConfig . AES_KEY ) String key ) throws Exception { final byte [ ] raw = key . getBytes ( NetworkConfig . getStringEncodingCharset ( ) ) ; final int keySize = raw . length ; if ( ( keySize % 16 ) == 0 || ( keySize % 24 ) == 0 || ( keySize % 32 ) == 0 ) { this . skeySpec = new SecretKeySpec ( raw , "AES" ) ; //$NON-NLS-1$ // this.cipher = Cipher.getInstance(ALGORITHM); } else { throw new IllegalArgumentException ( Messages . AESEventEncrypter_0 ) ; } } | Change the encryption key . | 157 | 5 |
33,563 | @ SuppressWarnings ( "static-method" ) protected void getLinkForPrimitive ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( type . typeName ( ) ) ; } | Build the link for the primitive . | 47 | 7 |
33,564 | protected void getLinkForAnnotationType ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( getTypeAnnotationLinks ( linkInfo ) ) ; linkInfo . type = type . asAnnotatedType ( ) . underlyingType ( ) ; link . addContent ( getLink ( linkInfo ) ) ; } | Build the link for the annotation type . | 71 | 8 |
33,565 | protected void getLinkForWildcard ( Content link , LinkInfo linkInfo , Type type ) { linkInfo . isTypeBound = true ; link . addContent ( "?" ) ; //$NON-NLS-1$ final WildcardType wildcardType = type . asWildcardType ( ) ; final Type [ ] extendsBounds = wildcardType . extendsBounds ( ) ; final SARLFeatureAccess kw = Utils . getKeywords ( ) ; for ( int i = 0 ; i < extendsBounds . length ; i ++ ) { link . addContent ( i > 0 ? kw . getCommaKeyword ( ) + " " //$NON-NLS-1$ : " " + kw . getExtendsKeyword ( ) + " " ) ; //$NON-NLS-1$ //$NON-NLS-2$ setBoundsLinkInfo ( linkInfo , extendsBounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } final Type [ ] superBounds = wildcardType . superBounds ( ) ; for ( int i = 0 ; i < superBounds . length ; i ++ ) { link . addContent ( i > 0 ? kw . getCommaKeyword ( ) + " " //$NON-NLS-1$ : " " + kw . getSuperKeyword ( ) + " " ) ; //$NON-NLS-1$ //$NON-NLS-2$ setBoundsLinkInfo ( linkInfo , superBounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } } | Build the link for the wildcard . | 360 | 8 |
33,566 | protected void getLinkForTypeVariable ( Content link , LinkInfo linkInfo , Type type ) { link . addContent ( getTypeAnnotationLinks ( linkInfo ) ) ; linkInfo . isTypeBound = true ; final Doc owner = type . asTypeVariable ( ) . owner ( ) ; if ( ( ! linkInfo . excludeTypeParameterLinks ) && owner instanceof ClassDoc ) { linkInfo . classDoc = ( ClassDoc ) owner ; final Content label = newContent ( ) ; label . addContent ( type . typeName ( ) ) ; linkInfo . label = label ; link . addContent ( getClassLink ( linkInfo ) ) ; } else { link . addContent ( type . typeName ( ) ) ; } final Type [ ] bounds = type . asTypeVariable ( ) . bounds ( ) ; if ( ! linkInfo . excludeTypeBounds ) { linkInfo . excludeTypeBounds = true ; final SARLFeatureAccess kw = Utils . getKeywords ( ) ; for ( int i = 0 ; i < bounds . length ; ++ i ) { link . addContent ( i > 0 ? " " + kw . getAmpersandKeyword ( ) + " " //$NON-NLS-1$ //$NON-NLS-2$ : " " + kw . getExtendsKeyword ( ) + " " ) ; //$NON-NLS-1$ //$NON-NLS-2$ setBoundsLinkInfo ( linkInfo , bounds [ i ] ) ; link . addContent ( getLink ( linkInfo ) ) ; } } } | Build the link for the type variable . | 344 | 8 |
33,567 | protected void setBoundsLinkInfo ( LinkInfo linkInfo , Type bound ) { Reflect . callProc ( this , LinkFactory . class , "setBoundsLinkInfo" , //$NON-NLS-1$ new Class < ? > [ ] { LinkInfo . class , Type . class } , linkInfo , bound ) ; } | Change the bounds into the link info . | 73 | 8 |
33,568 | protected Content getLinkForClass ( Content link , LinkInfo linkInfo , Type type ) { if ( linkInfo . isTypeBound && linkInfo . excludeTypeBoundsLinks ) { //Since we are excluding type parameter links, we should not //be linking to the type bound. link . addContent ( type . typeName ( ) ) ; link . addContent ( getTypeParameterLinks ( linkInfo ) ) ; return null ; } linkInfo . classDoc = type . asClassDoc ( ) ; final Content nlink = newContent ( ) ; nlink . addContent ( getClassLink ( linkInfo ) ) ; if ( linkInfo . includeTypeAsSepLink ) { nlink . addContent ( getTypeParameterLinks ( linkInfo , false ) ) ; } return nlink ; } | Build the link for the class . | 165 | 7 |
33,569 | protected void updateLinkLabel ( LinkInfo linkInfo ) { if ( linkInfo . type != null && linkInfo instanceof LinkInfoImpl ) { final LinkInfoImpl impl = ( LinkInfoImpl ) linkInfo ; final ClassDoc classdoc = linkInfo . type . asClassDoc ( ) ; if ( classdoc != null ) { final SARLFeatureAccess kw = Utils . getKeywords ( ) ; final String name = classdoc . qualifiedName ( ) ; if ( isPrefix ( name , kw . getProceduresName ( ) ) ) { linkInfo . label = createProcedureLambdaLabel ( impl ) ; } else if ( isPrefix ( name , kw . getFunctionsName ( ) ) ) { linkInfo . label = createFunctionLambdaLabel ( impl ) ; } } } } | Update the label of the given link with the SARL notation for lambdas . | 177 | 17 |
33,570 | protected Content createProcedureLambdaLabel ( LinkInfoImpl linkInfo ) { final ParameterizedType type = linkInfo . type . asParameterizedType ( ) ; if ( type != null ) { final Type [ ] arguments = type . typeArguments ( ) ; if ( arguments != null && arguments . length > 0 ) { return createLambdaLabel ( linkInfo , arguments , arguments . length ) ; } } return linkInfo . label ; } | Create the label for a procedure lambda . | 97 | 8 |
33,571 | @ SuppressWarnings ( "static-method" ) @ Provides @ Singleton public CompilerCommand provideSarlcCompilerCommand ( Provider < SarlBatchCompiler > compiler , Provider < SarlConfig > configuration , Provider < PathDetector > pathDetector , Provider < ProgressBarConfig > commandConfig ) { return new CompilerCommand ( compiler , configuration , pathDetector , commandConfig ) ; } | Provide the command for running the compiler . | 88 | 9 |
33,572 | @ SuppressWarnings ( "static-method" ) @ Provides @ Singleton public ProgressBarConfig getProgressBarConfig ( ConfigurationFactory configFactory , Injector injector ) { final ProgressBarConfig config = ProgressBarConfig . getConfiguration ( configFactory ) ; injector . injectMembers ( config ) ; return config ; } | Replies the instance of the compiler command configuration . | 69 | 10 |
33,573 | public static JvmType filterActiveProcessorType ( JvmType type , CommonTypeComputationServices services ) { if ( AccessorsProcessor . class . getName ( ) . equals ( type . getQualifiedName ( ) ) ) { return services . getTypeReferences ( ) . findDeclaredType ( SarlAccessorsProcessor . class , type ) ; } return type ; } | Filter the type in order to create the correct processor . | 83 | 11 |
33,574 | public ImageDescriptor forAgent ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . AGENT , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the agents . | 62 | 9 |
33,575 | public ImageDescriptor forBehavior ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . BEHAVIOR , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the behaviors . | 65 | 9 |
33,576 | public ImageDescriptor forCapacity ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . CAPACITY , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the capacities . | 64 | 9 |
33,577 | public ImageDescriptor forSkill ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . SKILL , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the skills . | 62 | 9 |
33,578 | public ImageDescriptor forEvent ( JvmVisibility visibility , int flags ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . EVENT , false , false , toFlags ( visibility ) , USE_LIGHT_ICONS ) , flags ) ; } | Replies the image descriptor for the events . | 61 | 9 |
33,579 | public ImageDescriptor forBehaviorUnit ( ) { return getDecorated ( getTypeImageDescriptor ( SarlElementType . BEHAVIOR_UNIT , false , false , toFlags ( JvmVisibility . PUBLIC ) , USE_LIGHT_ICONS ) , 0 ) ; } | Replies the image descriptor for the behavior units . | 66 | 10 |
33,580 | public ImageDescriptor forStaticConstructor ( ) { return getDecorated ( getMethodImageDescriptor ( false , toFlags ( JvmVisibility . PUBLIC ) ) , JavaElementImageDescriptor . CONSTRUCTOR | JavaElementImageDescriptor . STATIC ) ; } | Replies the image descriptor for the static constructors . | 62 | 11 |
33,581 | public static URL getPomTemplateLocation ( ) { final URL url = Resources . getResource ( NewSarlProjectWizard . class , POM_TEMPLATE_BASENAME ) ; assert url != null ; return url ; } | Replies the location of a template for the pom files . | 52 | 13 |
33,582 | protected boolean validateSARLSpecificElements ( IJavaProject javaProject ) { // Check if the "SARL" generation directory is a source folder. final IPath outputPath = SARLPreferences . getSARLOutputPathFor ( javaProject . getProject ( ) ) ; if ( outputPath == null ) { final String message = MessageFormat . format ( Messages . BuildSettingWizardPage_0 , SARLConfig . FOLDER_SOURCE_GENERATED ) ; final IStatus status = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , message ) ; handleFinishException ( getShell ( ) , new InvocationTargetException ( new CoreException ( status ) ) ) ; return false ; } if ( ! hasSourcePath ( javaProject , outputPath ) ) { final String message = MessageFormat . format ( Messages . SARLProjectCreationWizard_0 , toOSString ( outputPath ) , buildInvalidOutputPathMessageFragment ( javaProject ) ) ; final IStatus status = SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , message ) ; handleFinishException ( getShell ( ) , new InvocationTargetException ( new CoreException ( status ) ) ) ; return false ; } return true ; } | Validate the SARL properties of the new projects . | 272 | 11 |
33,583 | protected void createDefaultMavenPom ( IJavaProject project , String compilerCompliance ) { // Get the template resource. final URL templateUrl = getPomTemplateLocation ( ) ; if ( templateUrl != null ) { final String compliance = Strings . isNullOrEmpty ( compilerCompliance ) ? SARLVersion . MINIMAL_JDK_VERSION : compilerCompliance ; final String groupId = getDefaultMavenGroupId ( ) ; // Read the template and do string replacement. final StringBuilder content = new StringBuilder ( ) ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( templateUrl . openStream ( ) ) ) ) { String line = reader . readLine ( ) ; while ( line != null ) { line = line . replaceAll ( Pattern . quote ( "@GROUP_ID@" ) , groupId ) ; //$NON-NLS-1$ line = line . replaceAll ( Pattern . quote ( "@PROJECT_NAME@" ) , project . getElementName ( ) ) ; //$NON-NLS-1$ line = line . replaceAll ( Pattern . quote ( "@PROJECT_VERSION@" ) , DEFAULT_MAVEN_PROJECT_VERSION ) ; //$NON-NLS-1$ line = line . replaceAll ( Pattern . quote ( "@SARL_VERSION@" ) , SARLVersion . SARL_RELEASE_VERSION_MAVEN ) ; //$NON-NLS-1$ line = line . replaceAll ( Pattern . quote ( "@JAVA_VERSION@" ) , compliance ) ; //$NON-NLS-1$ line = line . replaceAll ( Pattern . quote ( "@FILE_ENCODING@" ) , Charset . defaultCharset ( ) . displayName ( ) ) ; //$NON-NLS-1$ content . append ( line ) . append ( "\n" ) ; //$NON-NLS-1$ line = reader . readLine ( ) ; } } catch ( IOException exception ) { throw new RuntimeIOException ( exception ) ; } // Write the pom final IFile pomFile = project . getProject ( ) . getFile ( "pom.xml" ) ; //$NON-NLS-1$ try ( StringInputStream is = new StringInputStream ( content . toString ( ) ) ) { pomFile . create ( is , true , new NullProgressMonitor ( ) ) ; } catch ( CoreException exception ) { throw new RuntimeException ( exception ) ; } catch ( IOException exception ) { throw new RuntimeIOException ( exception ) ; } } } | Create the default Maven pom file for the project . | 570 | 12 |
33,584 | @ SuppressWarnings ( "static-method" ) protected String getDefaultMavenGroupId ( ) { final String userdomain = System . getenv ( "userdomain" ) ; //$NON-NLS-1$ if ( Strings . isNullOrEmpty ( userdomain ) ) { return "com.foo" ; //$NON-NLS-1$ } final String [ ] elements = userdomain . split ( Pattern . quote ( "." ) ) ; //$NON-NLS-1$ final StringBuilder groupId = new StringBuilder ( ) ; for ( int i = elements . length - 1 ; i >= 0 ; -- i ) { if ( groupId . length ( ) > 0 ) { groupId . append ( "." ) ; //$NON-NLS-1$ } groupId . append ( elements [ i ] ) ; } return groupId . toString ( ) ; } | Replies the default group id for a maven project . | 198 | 12 |
33,585 | IWorkbenchPart getActivePart ( ) { final IWorkbenchWindow activeWindow = getWorkbench ( ) . getActiveWorkbenchWindow ( ) ; if ( activeWindow != null ) { final IWorkbenchPage activePage = activeWindow . getActivePage ( ) ; if ( activePage != null ) { return activePage . getActivePart ( ) ; } } return null ; } | Replies the active part in the workbench . | 81 | 10 |
33,586 | public static String getCurrentClasspath ( ) { final StringBuilder path = new StringBuilder ( ) ; for ( final URL url : getCurrentClassLoader ( ) . getURLs ( ) ) { if ( path . length ( ) > 0 ) { path . append ( File . pathSeparator ) ; } final File file = FileSystem . convertURLToFile ( url ) ; if ( file != null ) { path . append ( file . getAbsolutePath ( ) ) ; } } return path . toString ( ) ; } | Replies the current class path . | 112 | 7 |
33,587 | private static URLClassLoader getCurrentClassLoader ( ) { synchronized ( Boot . class ) { if ( dynamicClassLoader == null ) { final ClassLoader cl = ClassLoader . getSystemClassLoader ( ) ; if ( cl instanceof URLClassLoader ) { dynamicClassLoader = ( URLClassLoader ) cl ; } else { dynamicClassLoader = URLClassLoader . newInstance ( new URL [ 0 ] , cl ) ; } } return dynamicClassLoader ; } } | Replies the current class loader . | 96 | 7 |
33,588 | @ SuppressWarnings ( "checkstyle:nestedifdepth" ) public static void addToSystemClasspath ( String entries ) { if ( ! Strings . isNullOrEmpty ( entries ) ) { final List < URL > cp = new ArrayList <> ( ) ; final String [ ] individualEntries = entries . split ( Pattern . quote ( File . pathSeparator ) ) ; for ( final String entry : individualEntries ) { if ( ! Strings . isNullOrEmpty ( entry ) ) { URL url = FileSystem . convertStringToURL ( entry , false ) ; if ( url != null ) { // Normalize the folder name in order to have a "/" at the end of the name. // Without this "/" the class loader cannot find the resources. if ( URISchemeType . FILE . isURL ( url ) ) { final File file = FileSystem . convertURLToFile ( url ) ; if ( file != null && file . isDirectory ( ) ) { try { url = new URL ( URISchemeType . FILE . name ( ) , "" , file . getAbsolutePath ( ) + "/" ) ; //$NON-NLS-1$//$NON-NLS-2$ } catch ( MalformedURLException e ) { // } } } cp . add ( url ) ; } } } final URL [ ] newcp = new URL [ cp . size ( ) ] ; cp . toArray ( newcp ) ; synchronized ( Boot . class ) { dynamicClassLoader = URLClassLoader . newInstance ( newcp , ClassLoader . getSystemClassLoader ( ) ) ; } } } | Add the given entries to the system classpath . | 354 | 10 |
33,589 | public static void main ( String [ ] args ) { try { Object [ ] freeArgs = parseCommandLine ( args ) ; if ( JanusConfig . getSystemPropertyAsBoolean ( JanusConfig . JANUS_LOGO_SHOW_NAME , JanusConfig . JANUS_LOGO_SHOW . booleanValue ( ) ) ) { showJanusLogo ( ) ; } if ( freeArgs . length == 0 ) { showError ( Messages . Boot_3 , null ) ; // Event if showError never returns, add the return statement for // avoiding compilation error. return ; } final String agentToLaunch = freeArgs [ 0 ] . toString ( ) ; freeArgs = Arrays . copyOfRange ( freeArgs , 1 , freeArgs . length , String [ ] . class ) ; // Load the agent class final Class < ? extends Agent > agent = loadAgentClass ( agentToLaunch ) ; assert agent != null ; startJanus ( agent , freeArgs ) ; } catch ( EarlyExitException exception ) { // Be silent return ; } catch ( Throwable e ) { showError ( MessageFormat . format ( Messages . Boot_4 , e . getLocalizedMessage ( ) ) , e ) ; // Even if showError never returns, add the return statement for // avoiding compilation error. return ; } } | Main function that is parsing the command line and launching the first agent . | 281 | 14 |
33,590 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showError ( String message , Throwable exception ) { try ( PrintWriter logger = new PrintWriter ( getConsoleLogger ( ) ) ) { if ( message != null && ! message . isEmpty ( ) ) { logger . println ( message ) ; } else if ( exception != null ) { exception . printStackTrace ( logger ) ; } logger . println ( ) ; logger . flush ( ) ; showHelp ( logger , false ) ; showVersion ( true ) ; } } | Show an error message and exit . | 119 | 7 |
33,591 | public static String getProgramName ( ) { String programName = JanusConfig . getSystemProperty ( JanusConfig . JANUS_PROGRAM_NAME , null ) ; if ( Strings . isNullOrEmpty ( programName ) ) { programName = JanusConfig . JANUS_PROGRAM_NAME_VALUE ; } return programName ; } | Replies the name of the program . | 78 | 8 |
33,592 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showDefaults ( ) { final Properties defaultValues = new Properties ( ) ; JanusConfig . getDefaultValues ( defaultValues ) ; NetworkConfig . getDefaultValues ( defaultValues ) ; try ( OutputStream os = getConsoleLogger ( ) ) { defaultValues . storeToXML ( os , null ) ; os . flush ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } getExiter ( ) . exit ( ) ; } | Show the default values of the system properties . This function never returns . | 120 | 14 |
33,593 | @ SuppressWarnings ( { "resource" } ) public static void showClasspath ( ) { final String cp = getCurrentClasspath ( ) ; if ( ! Strings . isNullOrEmpty ( cp ) ) { final PrintStream ps = getConsoleLogger ( ) ; for ( final String entry : cp . split ( Pattern . quote ( File . pathSeparator ) ) ) { ps . println ( entry ) ; } ps . flush ( ) ; } getExiter ( ) . exit ( ) ; } | Show the classpath of the system properties . This function never returns . | 110 | 14 |
33,594 | public static void showVersion ( boolean exit ) { try ( PrintWriter logger = new PrintWriter ( getConsoleLogger ( ) ) ) { logger . println ( MessageFormat . format ( Messages . Boot_26 , JanusVersion . JANUS_RELEASE_VERSION ) ) ; logger . println ( MessageFormat . format ( Messages . Boot_27 , SARLVersion . SPECIFICATION_RELEASE_VERSION_STRING ) ) ; logger . flush ( ) ; } if ( exit ) { getExiter ( ) . exit ( ) ; } } | Show the version of Janus . | 116 | 7 |
33,595 | @ SuppressWarnings ( "checkstyle:regexp" ) public static void showCommandLineArguments ( String [ ] args ) { try ( PrintStream os = getConsoleLogger ( ) ) { for ( int i = 0 ; i < args . length ; ++ i ) { os . println ( i + ": " //$NON-NLS-1$ + args [ i ] ) ; } os . flush ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } getExiter ( ) . exit ( ) ; } | Show the command line arguments . This function never returns . | 124 | 11 |
33,596 | public static void setBootAgentTypeContextUUID ( ) { System . setProperty ( JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , Boolean . TRUE . toString ( ) ) ; System . setProperty ( JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; } | Force the Janus platform to use a default context identifier that tis build upon the classname of the boot agent . It means that the UUID is always the same for a given classname . | 78 | 40 |
33,597 | public static void setDefaultContextUUID ( ) { System . setProperty ( JanusConfig . BOOT_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; System . setProperty ( JanusConfig . RANDOM_DEFAULT_CONTEXT_ID_NAME , Boolean . FALSE . toString ( ) ) ; } | Force the Janus platform to use the identifier hard - coded in the source code for its default context . | 76 | 21 |
33,598 | public static Integer getSarlClassification ( ProgramElementDoc type ) { final AnnotationDesc annotation = Utils . findFirst ( type . annotations ( ) , it -> qualifiedNameEquals ( it . annotationType ( ) . qualifiedTypeName ( ) , getKeywords ( ) . getSarlElementTypeAnnotationName ( ) ) ) ; if ( annotation != null ) { final ElementValuePair [ ] pairs = annotation . elementValues ( ) ; if ( pairs != null && pairs . length > 0 ) { return ( ( Number ) pairs [ 0 ] . value ( ) . value ( ) ) . intValue ( ) ; } } return null ; } | Replies the SARL element type of the given type . | 138 | 12 |
33,599 | public static String fixHiddenMember ( String name ) { return name . replaceAll ( Pattern . quote ( HIDDEN_MEMBER_CHARACTER ) , Matcher . quoteReplacement ( HIDDEN_MEMBER_REPLACEMENT_CHARACTER ) ) ; } | Replies a fixed version of the given name assuming that it is an hidden action and reformating the reserved text . | 59 | 23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.