idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
33,700
private static void fireDefaultSREChanged ( ISREInstall previous , ISREInstall current ) { for ( final Object listener : SRE_LISTENERS . getListeners ( ) ) { ( ( ISREInstallChangedListener ) listener ) . defaultSREInstallChanged ( previous , current ) ; } }
Notifies registered listeners that the default SRE has changed .
33,701
public static boolean isPlatformSRE ( ISREInstall sre ) { if ( sre != null ) { LOCK . lock ( ) ; try { return platformSREInstalls . contains ( sre . getId ( ) ) ; } finally { LOCK . unlock ( ) ; } } return false ; }
Replies if the given SRE is provided by the Eclipse platform through an extension point .
33,702
public static void clearSREConfiguration ( ) throws CoreException { final SARLEclipsePlugin plugin = SARLEclipsePlugin . getDefault ( ) ; plugin . getPreferences ( ) . remove ( getCurrentPreferenceKey ( ) ) ; plugin . savePreferences ( ) ; }
Remove the SRE configuration information from the preferences .
33,703
private static void initializeSREExtensions ( ) { final MultiStatus status = new MultiStatus ( SARLEclipsePlugin . PLUGIN_ID , IStatus . OK , "Exceptions occurred" , null ) ; final IExtensionPoint extensionPoint = Platform . getExtensionRegistry ( ) . getExtensionPoint ( SARLEclipsePlugin . PLUGIN_ID , SARLEclipseConfig . EXTENSION_POINT_SARL_RUNTIME_ENVIRONMENT ) ; if ( extensionPoint != null ) { Object obj ; for ( final IConfigurationElement element : extensionPoint . getConfigurationElements ( ) ) { try { obj = element . createExecutableExtension ( "class" ) ; if ( obj instanceof ISREInstall ) { final ISREInstall sre = ( ISREInstall ) obj ; platformSREInstalls . add ( sre . getId ( ) ) ; ALL_SRE_INSTALLS . put ( sre . getId ( ) , sre ) ; } else { SARLEclipsePlugin . getDefault ( ) . logErrorMessage ( "Cannot instance extension point: " + element . getName ( ) ) ; } } catch ( CoreException e ) { status . add ( e . getStatus ( ) ) ; } } if ( ! status . isOK ( ) ) { SARLEclipsePlugin . getDefault ( ) . getLog ( ) . log ( status ) ; } } }
Initializes SRE extensions .
33,704
public static String getSREsAsXML ( IProgressMonitor monitor ) throws CoreException { initializeSREs ( ) ; try { final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; final Document xmldocument = builder . newDocument ( ) ; final Element rootElement = getXml ( xmldocument ) ; xmldocument . appendChild ( rootElement ) ; final TransformerFactory transFactory = TransformerFactory . newInstance ( ) ; final Transformer trans = transFactory . newTransformer ( ) ; try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { final DOMSource source = new DOMSource ( xmldocument ) ; final PrintWriter flot = new PrintWriter ( baos ) ; final StreamResult xmlStream = new StreamResult ( flot ) ; trans . transform ( source , xmlStream ) ; return new String ( baos . toByteArray ( ) ) ; } } catch ( Throwable e ) { throw new CoreException ( SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , e ) ) ; } }
Returns the listing of currently installed SREs as a single XML file .
33,705
@ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) private static String initializePersistedSREs ( ) { final String rawXml = SARLEclipsePlugin . getDefault ( ) . getPreferences ( ) . get ( getCurrentPreferenceKey ( ) , "" ) ; try { Element config = null ; if ( ! Strings . isNullOrEmpty ( rawXml ) ) { config = parseXML ( rawXml , true ) ; } else { final SARLEclipsePlugin plugin = SARLEclipsePlugin . getDefault ( ) ; if ( plugin . getBundle ( ) != null ) { final IPath stateLocation = plugin . getStateLocation ( ) ; final IPath stateFile = stateLocation . append ( "sreConfiguration.xml" ) ; final File file = stateFile . toFile ( ) ; if ( file . exists ( ) ) { try ( InputStream fileInputStream = new BufferedInputStream ( new FileInputStream ( file ) ) ) { config = parseXML ( fileInputStream , true ) ; } catch ( IOException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } } } } if ( config != null ) { final String defaultId = config . getAttribute ( "defaultSRE" ) ; final NodeList children = config . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; ++ i ) { try { final Node child = children . item ( i ) ; if ( "SRE" . equalsIgnoreCase ( child . getNodeName ( ) ) && child instanceof Element ) { final Element element = ( Element ) child ; final boolean isPlatform = Boolean . parseBoolean ( element . getAttribute ( "platform" ) ) ; final String id = element . getAttribute ( "id" ) ; if ( ! isPlatform || ! ( ALL_SRE_INSTALLS . containsKey ( id ) ) ) { final ISREInstall sre = createSRE ( element . getAttribute ( "class" ) , id ) ; if ( sre == null ) { throw new IOException ( "Invalid XML format of the SRE preferences of " + id ) ; } try { sre . setFromXML ( element ) ; } catch ( IOException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } ALL_SRE_INSTALLS . put ( id , sre ) ; if ( isPlatform ) { platformSREInstalls . add ( id ) ; } } else { final ISREInstall sre = ALL_SRE_INSTALLS . get ( id ) ; if ( sre != null ) { try { sre . setFromXML ( element ) ; } catch ( IOException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } } } } } catch ( IOException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } } return defaultId ; } } catch ( IOException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } return null ; }
This method loads installed SREs based an existing user preference or old SRE configurations file .
33,706
@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:variabledeclarationusagedistance" , "checkstyle:npathcomplexity" } ) private static void initializeSREs ( ) { ISREInstall [ ] newSREs = new ISREInstall [ 0 ] ; boolean savePrefs = false ; LOCK . lock ( ) ; final String previousDefault = defaultSREId ; try { if ( platformSREInstalls == null ) { platformSREInstalls = new HashSet < > ( ) ; ALL_SRE_INSTALLS . clear ( ) ; if ( enableSreExtensionPoints ) { initializeSREExtensions ( ) ; } final String predefinedDefaultId = Strings . nullToEmpty ( initializePersistedSREs ( ) ) ; newSREs = new ISREInstall [ ALL_SRE_INSTALLS . size ( ) ] ; ISREInstall initDefaultSRE = null ; final Iterator < ISREInstall > iterator = ALL_SRE_INSTALLS . values ( ) . iterator ( ) ; for ( int i = 0 ; iterator . hasNext ( ) ; ++ i ) { final ISREInstall sre = iterator . next ( ) ; newSREs [ i ] = sre ; if ( sre . getValidity ( ) . isOK ( ) ) { if ( initDefaultSRE == null && sre . getId ( ) . equals ( predefinedDefaultId ) ) { initDefaultSRE = sre ; } } } final String oldDefaultId = initDefaultSRE == null ? null : initDefaultSRE . getId ( ) ; defaultSREId = oldDefaultId ; savePrefs = true ; } if ( Strings . isNullOrEmpty ( defaultSREId ) ) { ISREInstall firstSRE = null ; ISREInstall firstValidSRE = null ; final Iterator < ISREInstall > iterator = ALL_SRE_INSTALLS . values ( ) . iterator ( ) ; while ( firstValidSRE == null && iterator . hasNext ( ) ) { final ISREInstall sre = iterator . next ( ) ; if ( firstSRE == null ) { firstSRE = sre ; } if ( sre . getValidity ( ) . isOK ( ) ) { firstValidSRE = sre ; } } if ( firstValidSRE == null ) { firstValidSRE = firstSRE ; } if ( firstValidSRE != null ) { savePrefs = true ; defaultSREId = firstValidSRE . getId ( ) ; } } } finally { LOCK . unlock ( ) ; } if ( savePrefs ) { safeSaveSREConfiguration ( ) ; } if ( newSREs . length > 0 ) { for ( final ISREInstall sre : newSREs ) { fireSREAdded ( sre ) ; } } if ( ! Objects . equal ( previousDefault , defaultSREId ) ) { fireDefaultSREChanged ( getSREFromId ( previousDefault ) , getSREFromId ( defaultSREId ) ) ; } }
Perform SRE install initialization . Does not hold locks while performing change notification .
33,707
public static String createUniqueIdentifier ( ) { String id ; do { id = UUID . randomUUID ( ) . toString ( ) ; } while ( getSREFromId ( id ) != null ) ; return id ; }
Replies an unique identifier .
33,708
public static boolean isUnpackedSRE ( File directory ) { File manifestFile = new File ( directory , "META-INF" ) ; manifestFile = new File ( manifestFile , "MANIFEST.MF" ) ; if ( manifestFile . canRead ( ) ) { try ( InputStream manifestStream = new FileInputStream ( manifestFile ) ) { final Manifest manifest = new Manifest ( manifestStream ) ; final Attributes sarlSection = manifest . getAttributes ( SREConstants . MANIFEST_SECTION_SRE ) ; if ( sarlSection == null ) { return false ; } final String sarlVersion = sarlSection . getValue ( SREConstants . MANIFEST_SARL_SPEC_VERSION ) ; if ( sarlVersion == null || sarlVersion . isEmpty ( ) ) { return false ; } final Version sarlVer = Version . parseVersion ( sarlVersion ) ; return sarlVer != null ; } catch ( IOException exception ) { return false ; } } return false ; }
Replies if the given directory contains a SRE .
33,709
public static boolean isPackedSRE ( File jarFile ) { try ( JarFile jFile = new JarFile ( jarFile ) ) { final Manifest manifest = jFile . getManifest ( ) ; if ( manifest == null ) { return false ; } final Attributes sarlSection = manifest . getAttributes ( SREConstants . MANIFEST_SECTION_SRE ) ; if ( sarlSection == null ) { return false ; } final String sarlVersion = sarlSection . getValue ( SREConstants . MANIFEST_SARL_SPEC_VERSION ) ; if ( sarlVersion == null || sarlVersion . isEmpty ( ) ) { return false ; } final Version sarlVer = Version . parseVersion ( sarlVersion ) ; return sarlVer != null ; } catch ( IOException exception ) { return false ; } }
Replies if the given JAR file contains a SRE .
33,710
public static String getDeclaredBootstrap ( IPath path ) { try { final IFile location = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; if ( location != null ) { final IPath pathLocation = location . getLocation ( ) ; if ( pathLocation != null ) { final File file = pathLocation . toFile ( ) ; if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { return getDeclaredBootstrapInFolder ( file ) ; } if ( file . isFile ( ) ) { return getDeclaredBootstrapInJar ( file ) ; } return null ; } } } final File file = path . makeAbsolute ( ) . toFile ( ) ; if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { return getDeclaredBootstrapInJar ( file ) ; } if ( file . isFile ( ) ) { return getDeclaredBootstrapInFolder ( file ) ; } } } catch ( Exception exception ) { } return null ; }
Replies the bootstrap name declared within the given path corresponding to a JAR file or a folder .
33,711
protected Object processElement ( Object obj , Class < ? > expectedType ) { if ( obj == null || obj instanceof Proxy ) { return obj ; } if ( obj instanceof Doc ) { return wrap ( obj ) ; } else if ( expectedType != null && expectedType . isArray ( ) ) { final Class < ? > componentType = expectedType . getComponentType ( ) ; if ( Doc . class . isAssignableFrom ( componentType ) ) { final int len = Array . getLength ( obj ) ; final List < Object > list = new ArrayList < > ( len ) ; final ApidocExcluder excluder = this . configuration . get ( ) . getApidocExcluder ( ) ; for ( int i = 0 ; i < len ; ++ i ) { final Object entry = Array . get ( obj , i ) ; if ( ! ( entry instanceof Doc ) ) { list . add ( processElement ( entry , componentType ) ) ; } else if ( excluder . isExcluded ( ( Doc ) entry ) ) { if ( excluder . isTranslatableToTag ( ( Doc ) entry ) ) { } } else { list . add ( processElement ( entry , componentType ) ) ; } } final Object newArray = Array . newInstance ( componentType , list . size ( ) ) ; int i = 0 ; for ( final Object element : list ) { Array . set ( newArray , i , element ) ; ++ i ; } return newArray ; } } return obj ; }
Filter the given document .
33,712
protected Object wrap ( Object object ) { if ( object == null || object instanceof Proxy ) { return object ; } final Class < ? > type = object . getClass ( ) ; return Proxy . newProxyInstance ( type . getClassLoader ( ) , type . getInterfaces ( ) , new ProxyHandler ( object ) ) ; }
Unwrap the given object .
33,713
protected void writePackageFiles ( QualifiedName name , String lineSeparator , IExtraLanguageGeneratorContext context ) { final IFileSystemAccess2 fsa = context . getFileSystemAccess ( ) ; final String outputConfiguration = getOutputConfigurationName ( ) ; QualifiedName libraryName = null ; for ( final String segment : name . skipLast ( 1 ) . getSegments ( ) ) { if ( libraryName == null ) { libraryName = QualifiedName . create ( segment , LIBRARY_FILENAME ) ; } else { libraryName = libraryName . append ( segment ) . append ( LIBRARY_FILENAME ) ; } final String fileName = toFilename ( libraryName ) ; if ( ! fsa . isFile ( fileName ) ) { final String content = PYTHON_FILE_HEADER + lineSeparator + getGenerationComment ( context ) + lineSeparator + LIBRARY_CONTENT ; if ( Strings . isEmpty ( outputConfiguration ) ) { fsa . generateFile ( fileName , content ) ; } else { fsa . generateFile ( fileName , outputConfiguration , content ) ; } } libraryName = libraryName . skipLast ( 1 ) ; } }
Generate the Python package files .
33,714
@ SuppressWarnings ( "static-method" ) protected boolean generatePythonClassDeclaration ( String typeName , boolean isAbstract , List < ? extends JvmTypeReference > superTypes , String comment , boolean ignoreObjectType , PyAppendable it , IExtraLanguageGeneratorContext context ) { if ( ! Strings . isEmpty ( typeName ) ) { it . append ( "class " ) . append ( typeName ) . append ( "(" ) ; boolean isOtherSuperType = false ; boolean first = true ; for ( final JvmTypeReference reference : superTypes ) { if ( ! ignoreObjectType || ! Strings . equal ( reference . getQualifiedName ( ) , Object . class . getCanonicalName ( ) ) ) { isOtherSuperType = true ; if ( first ) { first = false ; } else { it . append ( "," ) ; } it . append ( reference . getType ( ) ) ; } } if ( isOtherSuperType ) { it . append ( "," ) ; } it . append ( "object):" ) ; it . increaseIndentation ( ) . newLine ( ) ; generateDocString ( comment , it ) ; return true ; } return false ; }
Generate the type declaration for a Python class .
33,715
protected static boolean generateDocString ( String comment , PyAppendable it ) { final String cmt = comment == null ? null : comment . trim ( ) ; if ( ! Strings . isEmpty ( cmt ) ) { assert cmt != null ; it . append ( "\"\"\"" ) . increaseIndentation ( ) ; for ( final String line : cmt . split ( "[\n\r\f]+" ) ) { it . newLine ( ) . append ( line ) ; } it . decreaseIndentation ( ) . newLine ( ) ; it . append ( "\"\"\"" ) . newLine ( ) ; return true ; } return false ; }
Generate a Python docstring with the given comment .
33,716
protected static boolean generateBlockComment ( String comment , PyAppendable it ) { final String cmt = comment == null ? null : comment . trim ( ) ; if ( ! Strings . isEmpty ( cmt ) ) { assert cmt != null ; for ( final String line : cmt . split ( "[\n\r\f]+" ) ) { it . append ( "# " ) . append ( line ) . newLine ( ) ; } return true ; } return false ; }
Generate a Python block comment with the given comment .
33,717
@ SuppressWarnings ( { "checkstyle:parameternumber" } ) protected boolean generateTypeDeclaration ( String fullyQualifiedName , String name , boolean isAbstract , List < ? extends JvmTypeReference > superTypes , String comment , boolean ignoreObjectType , List < ? extends XtendMember > members , PyAppendable it , IExtraLanguageGeneratorContext context , Procedure2 < ? super PyAppendable , ? super IExtraLanguageGeneratorContext > memberGenerator ) { if ( ! Strings . isEmpty ( name ) ) { if ( ! generatePythonClassDeclaration ( name , isAbstract , superTypes , comment , ignoreObjectType , it , context ) || context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } it . openScope ( ) ; if ( ! generateSarlMembers ( members , it , context ) || context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } if ( memberGenerator != null ) { memberGenerator . apply ( it , context ) ; } if ( ! generatePythonConstructors ( fullyQualifiedName , members , it , context ) || context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } it . decreaseIndentation ( ) . newLine ( ) . newLine ( ) ; it . closeScope ( ) ; if ( context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } return true ; } return false ; }
Generate the given type .
33,718
protected boolean generateEnumerationDeclaration ( SarlEnumeration enumeration , PyAppendable it , IExtraLanguageGeneratorContext context ) { if ( ! Strings . isEmpty ( enumeration . getName ( ) ) ) { it . append ( "class " ) . append ( enumeration . getName ( ) ) ; it . append ( "(Enum" ) ; it . append ( newType ( "enum.Enum" ) ) ; it . append ( "):" ) ; it . increaseIndentation ( ) . newLine ( ) ; generateDocString ( getTypeBuilder ( ) . getDocumentation ( enumeration ) , it ) ; int i = 0 ; for ( final XtendMember item : enumeration . getMembers ( ) ) { if ( context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } if ( item instanceof XtendEnumLiteral ) { final XtendEnumLiteral literal = ( XtendEnumLiteral ) item ; it . append ( literal . getName ( ) ) . append ( " = " ) ; it . append ( Integer . toString ( i ) ) ; it . newLine ( ) ; ++ i ; } } it . decreaseIndentation ( ) . newLine ( ) . newLine ( ) ; return true ; } return false ; }
Generate the given enumeration declaration .
33,719
protected boolean generatePythonConstructors ( String container , List < ? extends XtendMember > members , PyAppendable it , IExtraLanguageGeneratorContext context ) { boolean hasConstructor = false ; for ( final XtendMember member : members ) { if ( context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } if ( member instanceof SarlConstructor ) { hasConstructor = true ; generate ( member , it , context ) ; it . newLine ( ) ; } } if ( context . getCancelIndicator ( ) . isCanceled ( ) ) { return false ; } if ( ! hasConstructor ) { it . append ( "def __init__(self):" ) ; it . increaseIndentation ( ) . newLine ( ) ; final List < SarlField > fields = context . getMultimapValues ( INSTANCE_VARIABLES_MEMENTO , container ) ; if ( fields . isEmpty ( ) ) { it . append ( "pass" ) ; } else { for ( final SarlField field : fields ) { generatePythonField ( field , it , context ) ; } } it . decreaseIndentation ( ) . newLine ( ) ; } return true ; }
Generate the constructors for a Python class .
33,720
@ SuppressWarnings ( "static-method" ) protected JvmType newType ( String pythonName ) { final JvmGenericType type = TypesFactory . eINSTANCE . createJvmGenericType ( ) ; final int index = pythonName . indexOf ( "." ) ; if ( index <= 0 ) { type . setSimpleName ( pythonName ) ; } else { type . setPackageName ( pythonName . substring ( 0 , index - 1 ) ) ; type . setSimpleName ( pythonName . substring ( index + 1 ) ) ; } return type ; }
Create a JvmType for a Python type .
33,721
protected void generatePythonField ( SarlField field , PyAppendable it , IExtraLanguageGeneratorContext context ) { generateBlockComment ( getTypeBuilder ( ) . getDocumentation ( field ) , it ) ; if ( ! field . isStatic ( ) ) { it . append ( "self." ) ; } final String fieldName = it . declareUniqueNameVariable ( field , field . getName ( ) ) ; it . append ( fieldName ) ; it . append ( " = " ) ; if ( field . getInitialValue ( ) != null ) { generate ( field . getInitialValue ( ) , null , it , context ) ; } else { it . append ( PyExpressionGenerator . toDefaultValue ( field . getType ( ) ) ) ; } it . newLine ( ) ; }
Create a field declaration .
33,722
protected void generateGuardEvaluators ( String container , PyAppendable it , IExtraLanguageGeneratorContext context ) { final Map < String , Map < String , List < Pair < XExpression , String > > > > allGuardEvaluators = context . getMapData ( EVENT_GUARDS_MEMENTO ) ; final Map < String , List < Pair < XExpression , String > > > guardEvaluators = allGuardEvaluators . get ( container ) ; if ( guardEvaluators == null ) { return ; } boolean first = true ; for ( final Entry < String , List < Pair < XExpression , String > > > entry : guardEvaluators . entrySet ( ) ) { if ( first ) { first = false ; } else { it . newLine ( ) ; } it . append ( "def __guard_" ) ; it . append ( entry . getKey ( ) . replaceAll ( "[^a-zA-Z0-9_]+" , "_" ) ) ; it . append ( "__(self, occurrence):" ) ; it . increaseIndentation ( ) . newLine ( ) ; it . append ( "it = occurrence" ) . newLine ( ) ; final String eventHandleName = it . declareUniqueNameVariable ( new Object ( ) , "__event_handles" ) ; it . append ( eventHandleName ) . append ( " = list" ) ; for ( final Pair < XExpression , String > guardDesc : entry . getValue ( ) ) { it . newLine ( ) ; if ( guardDesc . getKey ( ) == null ) { it . append ( eventHandleName ) . append ( ".add(" ) . append ( guardDesc . getValue ( ) ) . append ( ")" ) ; } else { it . append ( "if " ) ; generate ( guardDesc . getKey ( ) , null , it , context ) ; it . append ( ":" ) . increaseIndentation ( ) . newLine ( ) ; it . append ( eventHandleName ) . append ( ".add(" ) . append ( guardDesc . getValue ( ) ) . append ( ")" ) ; it . decreaseIndentation ( ) ; } } it . newLine ( ) . append ( "return " ) . append ( eventHandleName ) ; it . decreaseIndentation ( ) . newLine ( ) ; } }
Generate the memorized guard evaluators .
33,723
protected void _before ( SarlCapacityUses uses , IExtraLanguageGeneratorContext context ) { for ( final JvmTypeReference capacity : uses . getCapacities ( ) ) { final JvmType type = capacity . getType ( ) ; if ( type instanceof JvmDeclaredType ) { computeCapacityFunctionMarkers ( ( JvmDeclaredType ) type ) ; } } }
Mark the functions of the used capacities in order to have a valid feature call within the code .
33,724
@ Check ( CheckType . NORMAL ) public void checkExtraLanguageRules ( EObject currentObject ) { final List < AbstractExtraLanguageValidator > validators = this . validatorProvider . getValidators ( currentObject . eResource ( ) ) ; if ( ! validators . isEmpty ( ) ) { for ( final AbstractExtraLanguageValidator validator : validators ) { final ValidationMessageAcceptor acceptor = getMessageAcceptor ( ) ; final StateAccess stateAccess = setMessageAcceptor ( acceptor ) ; validator . validate ( stateAccess , acceptor ) ; } } }
Check the rules for the activated extra languages .
33,725
public void setComment ( String comment ) { this . comment = comment ; if ( ! Strings . isEmpty ( comment ) ) { this . name = MessageFormat . format ( "{0} [{1}]" , getClass ( ) . getName ( ) , comment ) ; } else { this . name = getClass ( ) . getName ( ) ; } }
Change the comment for the injection fragment .
33,726
protected GeneratorConfig createDefaultGeneratorConfig ( ) { final GeneratorConfig config = new GeneratorConfig ( ) ; if ( this . defaultVersion == null ) { this . defaultVersion = JavaVersion . fromQualifier ( System . getProperty ( "java.specification.version" ) ) ; if ( this . defaultVersion != null ) { config . setJavaSourceVersion ( this . defaultVersion ) ; } } else { config . setJavaSourceVersion ( this . defaultVersion ) ; } return config ; }
Invoked for creating the default generator configuration .
33,727
protected InferredPrototype createPrototype ( QualifiedActionName id , boolean isVarargs , FormalParameterProvider parameters ) { assert parameters != null ; final ActionParameterTypes key = new ActionParameterTypes ( isVarargs , parameters . getFormalParameterCount ( ) ) ; final Map < ActionParameterTypes , List < InferredStandardParameter > > ip = buildSignaturesForArgDefaultValues ( id . getDeclaringType ( ) , key . toActionPrototype ( id . getActionName ( ) ) . toActionId ( ) , parameters , key ) ; final List < InferredStandardParameter > op = ip . remove ( key ) ; final InferredPrototype proto = new DefaultInferredPrototype ( id , parameters , key , op , ip ) ; final String containerID = id . getContainerID ( ) ; Map < String , Map < ActionParameterTypes , InferredPrototype > > c = this . prototypes . get ( containerID ) ; if ( c == null ) { c = new TreeMap < > ( ) ; this . prototypes . put ( containerID , c ) ; } Map < ActionParameterTypes , InferredPrototype > list = c . get ( id . getActionName ( ) ) ; if ( list == null ) { list = new TreeMap < > ( ) ; c . put ( id . getActionName ( ) , list ) ; } list . put ( key , proto ) ; return proto ; }
Build and replies the inferred action signature for the element with the given ID . This function creates the different signatures according to the definition or not of default values for the formal parameters .
33,728
@ SuppressWarnings ( "static-method" ) public ITextReplacerContext fix ( final ITextReplacerContext context , IComment comment ) { final IHiddenRegion hiddenRegion = comment . getHiddenRegion ( ) ; if ( detectBugSituation ( hiddenRegion ) && fixBug ( hiddenRegion ) ) { final ITextRegionAccess access = comment . getTextRegionAccess ( ) ; final ITextSegment target = access . regionForOffset ( comment . getOffset ( ) , 0 ) ; context . addReplacement ( target . replaceWith ( context . getIndentationString ( 1 ) ) ) ; return new FixedReplacementContext ( context ) ; } return context ; }
Fixing the bug .
33,729
public void putDefaultClasspathEntriesIn ( Collection < IClasspathEntry > classpathEntries ) { final IPath newPath = this . jreGroup . getJREContainerPath ( ) ; if ( newPath != null ) { classpathEntries . add ( JavaCore . newContainerEntry ( newPath ) ) ; } else { final IClasspathEntry [ ] entries = PreferenceConstants . getDefaultJRELibrary ( ) ; classpathEntries . addAll ( Arrays . asList ( entries ) ) ; } final IClasspathEntry sarlClasspathEntry = JavaCore . newContainerEntry ( SARLClasspathContainerInitializer . CONTAINER_ID , new IAccessRule [ 0 ] , new IClasspathAttribute [ 0 ] , true ) ; classpathEntries . add ( sarlClasspathEntry ) ; }
Returns the default class path entries to be added on new projects . By default this is the JRE container as selected by the user .
33,730
public IPath getOutputLocation ( ) { IPath outputLocationPath = new Path ( getProjectName ( ) ) . makeAbsolute ( ) ; outputLocationPath = outputLocationPath . append ( Path . fromPortableString ( SARLConfig . FOLDER_BIN ) ) ; return outputLocationPath ; }
Returns the source class path entries to be added on new projects . The underlying resource may not exist .
33,731
protected static Action findAction ( EObject grammarComponent , String assignmentName ) { for ( final Action action : GrammarUtil . containedActions ( grammarComponent ) ) { if ( GrammarUtil . isAssignedAction ( action ) ) { if ( Objects . equals ( assignmentName , action . getFeature ( ) ) ) { return action ; } } } return null ; }
Replies the assignment component with the given nazme in the given grammar component .
33,732
protected EObject getContainerInRule ( EObject root , EObject content ) { EObject container = content ; do { final EClassifier classifier = getGeneratedTypeFor ( container ) ; if ( classifier != null ) { return container ; } container = container . eContainer ( ) ; } while ( container != root ) ; final EClassifier classifier = getGeneratedTypeFor ( root ) ; if ( classifier != null ) { return root ; } return null ; }
Replies the container in the grammar rule for the given content element .
33,733
protected CellEditor createClassCellEditor ( ) { return new DialogCellEditor ( getControl ( ) ) { protected Object openDialogBox ( Control cellEditorWindow ) { final OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog ( getControl ( ) . getShell ( ) , false , PlatformUI . getWorkbench ( ) . getProgressService ( ) , null , IJavaSearchConstants . TYPE ) ; dialog . setTitle ( JavaUIMessages . OpenTypeAction_dialogTitle ) ; dialog . setMessage ( JavaUIMessages . OpenTypeAction_dialogMessage ) ; final int result = dialog . open ( ) ; if ( result != IDialogConstants . OK_ID ) { return null ; } final Object [ ] types = dialog . getResult ( ) ; if ( types == null || types . length != 1 || ! ( types [ 0 ] instanceof IType ) ) { return null ; } final IType type = ( IType ) types [ 0 ] ; final String name = type . getFullyQualifiedName ( ) ; return Strings . emptyIfNull ( name ) ; } } ; }
Create a cell editor that enables to select a class .
33,734
private void enableButtons ( ) { final int itemCount = this . list . getTable ( ) . getItemCount ( ) ; final boolean hasElement = itemCount > 0 ; IStructuredSelection selection ; if ( hasElement ) { selection = this . list . getStructuredSelection ( ) ; final int selectionCount = selection . size ( ) ; if ( selectionCount <= 0 || selectionCount > itemCount ) { selection = null ; } } else { selection = null ; } this . removeButton . setEnabled ( selection != null ) ; this . clearButton . setEnabled ( hasElement ) ; if ( this . isSortedElements ) { final Object firstElement = selection != null ? this . list . getTable ( ) . getItem ( 0 ) . getData ( ) : null ; final Object lastElement = selection != null ? this . list . getTable ( ) . getItem ( this . list . getTable ( ) . getItemCount ( ) - 1 ) . getData ( ) : null ; final boolean isNotFirst = firstElement != null && selection != null && firstElement != selection . getFirstElement ( ) ; final boolean isNotLast = lastElement != null && selection != null && lastElement != selection . getFirstElement ( ) ; this . moveTopButton . setEnabled ( isNotFirst ) ; this . moveUpButton . setEnabled ( isNotFirst ) ; this . moveDownButton . setEnabled ( isNotLast ) ; this . moveBottomButton . setEnabled ( isNotLast ) ; } }
Enables the type conversion buttons based on selected items counts in the viewer .
33,735
protected void setTypeConversions ( List < Pair < String , String > > typeConversions , boolean notifyController ) { this . conversions . clear ( ) ; if ( typeConversions != null ) { for ( final Pair < String , String > entry : typeConversions ) { this . conversions . add ( new ConversionMapping ( entry . getKey ( ) , entry . getValue ( ) ) ) ; } } this . list . setInput ( this . conversions ) ; refreshListUI ( ) ; if ( notifyController ) { preferenceValueChanged ( ) ; } }
Sets the type conversions to be displayed in this block .
33,736
protected void addTypeConversion ( String javaType , String targetType , boolean updateSelection ) { final ConversionMapping entry = new ConversionMapping ( javaType , targetType ) ; this . conversions . add ( entry ) ; refreshListUI ( ) ; if ( updateSelection ) { this . list . setSelection ( new StructuredSelection ( entry ) ) ; } if ( ! this . list . isBusy ( ) ) { this . list . refresh ( true ) ; } enableButtons ( ) ; preferenceValueChanged ( ) ; }
Add a type conversion .
33,737
@ SuppressWarnings ( "unchecked" ) protected void removeCurrentTypeConversion ( ) { final IStructuredSelection selection = this . list . getStructuredSelection ( ) ; final String [ ] types = new String [ selection . size ( ) ] ; final Iterator < ConversionMapping > iter = selection . iterator ( ) ; int i = 0 ; while ( iter . hasNext ( ) ) { types [ i ] = iter . next ( ) . getSource ( ) ; i ++ ; } removeTypeConversions ( types ) ; }
Remove the current type conversion .
33,738
protected void moveSelectionTop ( ) { final IStructuredSelection selection = this . list . getStructuredSelection ( ) ; final int index = this . conversions . indexOf ( selection . getFirstElement ( ) ) ; if ( index > 0 ) { final int endIndex = index + selection . size ( ) - 1 ; for ( int i = 0 ; i < selection . size ( ) ; ++ i ) { final ConversionMapping next = this . conversions . remove ( endIndex ) ; this . conversions . addFirst ( next ) ; } refreshListUI ( ) ; this . list . refresh ( true ) ; enableButtons ( ) ; preferenceValueChanged ( ) ; } }
Move the selection at the top .
33,739
protected void moveSelectionUp ( ) { final IStructuredSelection selection = this . list . getStructuredSelection ( ) ; final int index = this . conversions . indexOf ( selection . getFirstElement ( ) ) ; if ( index > 0 ) { final ConversionMapping previous = this . conversions . remove ( index - 1 ) ; this . conversions . add ( index + selection . size ( ) - 1 , previous ) ; refreshListUI ( ) ; this . list . refresh ( true ) ; enableButtons ( ) ; preferenceValueChanged ( ) ; } }
Move the selection up .
33,740
protected void moveSelectionDown ( ) { final IStructuredSelection selection = this . list . getStructuredSelection ( ) ; final int index = this . conversions . indexOf ( selection . getFirstElement ( ) ) ; if ( index >= 0 && ( index + selection . size ( ) ) < this . conversions . size ( ) ) { final ConversionMapping next = this . conversions . remove ( index + selection . size ( ) ) ; this . conversions . add ( index , next ) ; refreshListUI ( ) ; this . list . refresh ( true ) ; enableButtons ( ) ; preferenceValueChanged ( ) ; } }
Move the selection down .
33,741
protected void moveSelectionBottom ( ) { final IStructuredSelection selection = this . list . getStructuredSelection ( ) ; final int index = this . conversions . indexOf ( selection . getFirstElement ( ) ) ; if ( index >= 0 && ( index + selection . size ( ) ) < this . conversions . size ( ) ) { for ( int i = 0 ; i < selection . size ( ) ; ++ i ) { final ConversionMapping previous = this . conversions . remove ( index ) ; this . conversions . addLast ( previous ) ; } refreshListUI ( ) ; this . list . refresh ( true ) ; enableButtons ( ) ; preferenceValueChanged ( ) ; } }
Move the selection at the bottom .
33,742
protected void removeTypeConversions ( String ... types ) { for ( final String type : types ) { final Iterator < ConversionMapping > iterator = this . conversions . iterator ( ) ; while ( iterator . hasNext ( ) ) { final ConversionMapping pair = iterator . next ( ) ; if ( Strings . equal ( pair . getSource ( ) , type ) ) { iterator . remove ( ) ; break ; } } } refreshListUI ( ) ; this . list . refresh ( true ) ; enableButtons ( ) ; preferenceValueChanged ( ) ; }
Remove the given type conversions .
33,743
protected void refreshListUI ( ) { final Display display = Display . getDefault ( ) ; if ( display . getThread ( ) . equals ( Thread . currentThread ( ) ) ) { if ( ! this . list . isBusy ( ) ) { this . list . refresh ( ) ; } } else { display . syncExec ( new Runnable ( ) { @ SuppressWarnings ( "synthetic-access" ) public void run ( ) { if ( ! AbstractConversionTable . this . list . isBusy ( ) ) { AbstractConversionTable . this . list . refresh ( ) ; } } } ) ; } }
Refresh the UI list of type conversions .
33,744
private void sortByTargetColumn ( ) { this . list . setComparator ( new ViewerComparator ( ) { public int compare ( Viewer viewer , Object e1 , Object e2 ) { if ( e1 != null && e2 != null ) { return e1 . toString ( ) . compareToIgnoreCase ( e2 . toString ( ) ) ; } return super . compare ( viewer , e1 , e2 ) ; } public boolean isSorterProperty ( Object element , String property ) { return true ; } } ) ; this . sort = Column . TARGET ; }
Sorts the type conversions by target type .
33,745
private void updateStatus ( Throwable event ) { Throwable cause = event ; while ( cause != null && ( ! ( cause instanceof CoreException ) ) && cause . getCause ( ) != null && cause . getCause ( ) != cause ) { cause = cause . getCause ( ) ; } if ( cause instanceof CoreException ) { updateStatus ( ( ( CoreException ) cause ) . getStatus ( ) ) ; } else { final String message ; if ( cause != null ) { message = cause . getLocalizedMessage ( ) ; } else { message = event . getLocalizedMessage ( ) ; } final IStatus status = new StatusInfo ( IStatus . ERROR , message ) ; updateStatus ( status ) ; } }
Update the status of this page according to the given exception .
33,746
public void performFinish ( IProgressMonitor monitor ) throws CoreException , InterruptedException { final SubMonitor subMonitor = SubMonitor . convert ( monitor , 4 ) ; try { monitor . beginTask ( NewWizardMessages . NewJavaProjectWizardPageTwo_operation_create , 3 ) ; if ( this . currProject == null ) { updateProject ( subMonitor . newChild ( 1 ) ) ; } final String newProjectCompliance = this . keepContent ? null : this . firstPage . getCompilerCompliance ( ) ; configureJavaProject ( newProjectCompliance , subMonitor . newChild ( 1 ) ) ; } catch ( Throwable e ) { if ( this . currProject != null ) { removeProvisonalProject ( ) ; } throw e ; } finally { subMonitor . done ( ) ; this . currProject = null ; if ( this . isAutobuild != null ) { CoreUtility . setAutoBuilding ( this . isAutobuild . booleanValue ( ) ) ; this . isAutobuild = null ; } } }
Called from the wizard on finish .
33,747
protected IProject createProvisonalProject ( ) { final IStatus status = changeToNewProject ( ) ; if ( status != null ) { updateStatus ( status ) ; if ( ! status . isOK ( ) ) { ErrorDialog . openError ( getShell ( ) , NewWizardMessages . NewJavaProjectWizardPageTwo_error_title , null , status ) ; } } return this . currProject ; }
Creates the provisional project on which the wizard is working on . The provisional project is typically created when the page is entered the first time . The early project creation is required to configure linked folders .
33,748
protected void removeProvisonalProject ( ) { if ( ! this . currProject . exists ( ) ) { this . currProject = null ; return ; } final IRunnableWithProgress op = new IRunnableWithProgress ( ) { @ SuppressWarnings ( "synthetic-access" ) public void run ( IProgressMonitor monitor ) throws InvocationTargetException , InterruptedException { doRemoveProject ( monitor ) ; } } ; try { getContainer ( ) . run ( true , true , new WorkspaceModifyDelegatingOperation ( op ) ) ; } catch ( InvocationTargetException e ) { final String title = NewWizardMessages . NewJavaProjectWizardPageTwo_error_remove_title ; final String message = NewWizardMessages . NewJavaProjectWizardPageTwo_error_remove_message ; ExceptionHandler . handle ( e , getShell ( ) , title , message ) ; } catch ( InterruptedException e ) { } }
Removes the provisional project . The provisional project is typically removed when the user cancels the wizard or goes back to the first page .
33,749
public ADDRESST registerParticipant ( ADDRESST address , EventListener entity ) { synchronized ( mutex ( ) ) { addListener ( address , entity ) ; this . participants . put ( entity . getID ( ) , address ) ; } return address ; }
Registers a new participant in this repository .
33,750
public ADDRESST unregisterParticipant ( UUID entityID ) { synchronized ( mutex ( ) ) { removeListener ( this . participants . get ( entityID ) ) ; return this . participants . remove ( entityID ) ; } }
Remove a participant with the given ID from this repository .
33,751
public SynchronizedCollection < ADDRESST > getParticipantAddresses ( ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedCollection ( this . participants . values ( ) , mutex ) ; } }
Replies all the addresses of the participants that ar einside this repository .
33,752
public SynchronizedSet < UUID > getParticipantIDs ( ) { final Object mutex = mutex ( ) ; synchronized ( mutex ) { return Collections3 . synchronizedSet ( this . participants . keySet ( ) , mutex ) ; } }
Replies the identifiers of all the participants in this repository .
33,753
protected void addSourceFolder ( String path ) { final List < String > existingFolders1 = this . project . getCompileSourceRoots ( ) ; final List < String > existingFolders2 = this . project . getTestCompileSourceRoots ( ) ; if ( ! existingFolders1 . contains ( path ) && ! existingFolders2 . contains ( path ) ) { getLog ( ) . info ( MessageFormat . format ( Messages . InitializeMojo_0 , path ) ) ; this . session . getCurrentProject ( ) . addCompileSourceRoot ( path ) ; } else { getLog ( ) . info ( MessageFormat . format ( Messages . InitializeMojo_1 , path ) ) ; } }
Add a source folder in the current projecT .
33,754
private List < LightweightTypeReference > cloneTypeReferences ( List < JvmTypeReference > types , Map < String , JvmTypeReference > typeParameterMap ) { final List < LightweightTypeReference > newList = new ArrayList < > ( types . size ( ) ) ; for ( final JvmTypeReference type : types ) { newList . add ( cloneTypeReference ( type , typeParameterMap ) ) ; } return newList ; }
Clone the given types by applying the type parameter mapping when necessary .
33,755
@ BQConfigProperty ( "Specify the levels of specific warnings" ) public void setWarningLevels ( Map < String , Severity > levels ) { if ( levels == null ) { this . warningLevels = new HashMap < > ( ) ; } else { this . warningLevels = levels ; } }
Change the specific warning levels .
33,756
protected static String quoteRegex ( String regex ) { if ( regex == null ) { return "" ; } return regex . replaceAll ( REGEX_SPECIAL_CHARS , REGEX_SPECIAL_CHARS_PROTECT ) ; }
Protect the given regular expression .
33,757
protected static String orRegex ( Iterable < String > elements ) { final StringBuilder regex = new StringBuilder ( ) ; for ( final String element : elements ) { if ( regex . length ( ) > 0 ) { regex . append ( "|" ) ; } regex . append ( "(?:" ) ; regex . append ( quoteRegex ( element ) ) ; regex . append ( ")" ) ; } return regex . toString ( ) ; }
Build a regular expression that is matching one of the given elements .
33,758
protected static Set < String > sortedConcat ( Iterable < String > ... iterables ) { final Set < String > set = new TreeSet < > ( ) ; for ( final Iterable < String > iterable : iterables ) { for ( final String obj : iterable ) { set . add ( obj ) ; } } return set ; }
Concat the given iterables .
33,759
public void addMimeType ( String mimeType ) { if ( ! Strings . isEmpty ( mimeType ) ) { for ( final String mtype : mimeType . split ( "[:;,]" ) ) { this . mimeTypes . add ( mtype ) ; } } }
Add a mime type for the SARL source code .
33,760
public List < String > getMimeTypes ( ) { if ( this . mimeTypes . isEmpty ( ) ) { return Arrays . asList ( "text/x-" + getLanguageSimpleName ( ) . toLowerCase ( ) ) ; } return this . mimeTypes ; }
Replies the mime types for the SARL source code .
33,761
public String getBasename ( String defaultName ) { if ( Strings . isEmpty ( this . basename ) ) { return defaultName ; } return this . basename ; }
Replies the basename of the XML file to generate .
33,762
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) private static void exploreGrammar ( Grammar grammar , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > literals , Set < String > excludedKeywords , Set < String > ignored ) { for ( final AbstractRule rule : grammar . getRules ( ) ) { final boolean isModifierRule = MODIFIER_RULE_PATTERN . matcher ( rule . getName ( ) ) . matches ( ) ; final TreeIterator < EObject > iterator = rule . eAllContents ( ) ; while ( iterator . hasNext ( ) ) { final EObject object = iterator . next ( ) ; if ( object instanceof Keyword ) { final Keyword xkeyword = ( Keyword ) object ; final String value = xkeyword . getValue ( ) ; if ( ! Strings . isEmpty ( value ) ) { if ( KEYWORD_PATTERN . matcher ( value ) . matches ( ) ) { if ( ! literals . contains ( value ) && ! primitiveTypes . contains ( value ) ) { if ( excludedKeywords . contains ( value ) ) { ignored . add ( value ) ; } else { if ( isModifierRule ) { modifiers . add ( value ) ; } else { expressionKeywords . add ( value ) ; } } } } else if ( PUNCTUATION_PATTERN . matcher ( value ) . matches ( ) ) { punctuation . add ( value ) ; } } } } } }
Explore the grammar for extracting the key elements .
33,763
protected final void generate ( Set < String > literals , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > ignored , Set < String > specialKeywords , Set < String > typeDeclarationKeywords ) { final T appendable = newStyleAppendable ( ) ; generate ( appendable , literals , expressionKeywords , modifiers , primitiveTypes , punctuation , ignored , specialKeywords , typeDeclarationKeywords ) ; final String language = getLanguageSimpleName ( ) . toLowerCase ( ) ; final String basename = getBasename ( MessageFormat . format ( getBasenameTemplate ( ) , language ) ) ; writeFile ( basename , appendable ) ; generateAdditionalFiles ( basename , appendable ) ; generateReadme ( basename ) ; }
Generate the external specification .
33,764
public static CharSequence concat ( CharSequence ... lines ) { return new CharSequence ( ) { private final StringBuilder content = new StringBuilder ( ) ; private int next ; private int length = - 1 ; public String toString ( ) { ensure ( length ( ) ) ; return this . content . toString ( ) ; } private void ensure ( int index ) { while ( this . next < lines . length && index >= this . content . length ( ) ) { if ( lines [ this . next ] != null ) { this . content . append ( lines [ this . next ] ) . append ( "\n" ) ; } ++ this . next ; } } public CharSequence subSequence ( int start , int end ) { ensure ( end - 1 ) ; return this . content . subSequence ( start , end ) ; } public int length ( ) { if ( this . length < 0 ) { int len = 0 ; for ( final CharSequence seq : lines ) { len += seq . length ( ) + 1 ; } len = Math . max ( 0 , len - 1 ) ; this . length = len ; } return this . length ; } public char charAt ( int index ) { ensure ( index ) ; return this . content . charAt ( index ) ; } } ; }
Contact the given strings of characters .
33,765
protected void generateReadme ( String basename ) { final Object content = getReadmeFileContent ( basename ) ; if ( content != null ) { final String textualContent = content . toString ( ) ; if ( ! Strings . isEmpty ( textualContent ) ) { final byte [ ] bytes = textualContent . getBytes ( ) ; for ( final String output : getOutputs ( ) ) { final File directory = new File ( output ) . getAbsoluteFile ( ) ; try { directory . mkdirs ( ) ; final File outputFile = new File ( directory , README_BASENAME ) ; Files . write ( Paths . get ( outputFile . getAbsolutePath ( ) ) , bytes ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } } }
Generate the README file .
33,766
protected String getLanguageSimpleName ( ) { final String name = getGrammar ( ) . getName ( ) ; final int index = name . lastIndexOf ( '.' ) ; if ( index > 0 ) { return name . substring ( index + 1 ) ; } return name ; }
Replies the simple name of the language .
33,767
protected String lines ( String prefix , String ... lines ) { final String delimiter = getCodeConfig ( ) . getLineDelimiter ( ) ; final StringBuilder buffer = new StringBuilder ( ) ; for ( final String line : lines ) { buffer . append ( prefix ) ; buffer . append ( line ) ; buffer . append ( delimiter ) ; } return buffer . toString ( ) ; }
Merge the given lines with prefix .
33,768
@ SuppressWarnings ( "static-method" ) protected OutputConfiguration createStandardOutputConfiguration ( ) { final OutputConfiguration defaultOutput = new OutputConfiguration ( IFileSystemAccess . DEFAULT_OUTPUT ) ; defaultOutput . setDescription ( Messages . SarlOutputConfigurationProvider_0 ) ; defaultOutput . setOutputDirectory ( SARLConfig . FOLDER_SOURCE_GENERATED ) ; defaultOutput . setOverrideExistingResources ( true ) ; defaultOutput . setCreateOutputDirectory ( true ) ; defaultOutput . setCanClearOutputDirectory ( false ) ; defaultOutput . setCleanUpDerivedResources ( true ) ; defaultOutput . setSetDerivedProperty ( true ) ; defaultOutput . setKeepLocalHistory ( false ) ; return defaultOutput ; }
Create the standard output configuration .
33,769
public static AgentContext getKernel ( ContextSpaceService contextService , @ Named ( JanusConfig . DEFAULT_CONTEXT_ID_NAME ) UUID janusContextID , @ Named ( JanusConfig . DEFAULT_SPACE_ID_NAME ) UUID defaultJanusSpaceId ) { return contextService . createContext ( janusContextID , defaultJanusSpaceId ) ; }
Construct the root agent context within the Janus platform .
33,770
public static AgentInternalEventsDispatcher createAgentInternalEventsDispatcher ( Injector injector ) { final AgentInternalEventsDispatcher aeb = new AgentInternalEventsDispatcher ( injector . getInstance ( ExecutorService . class ) ) ; injector . injectMembers ( aeb ) ; return aeb ; }
Create an instance of the event dispatcher for an agent .
33,771
protected LightweightTypeReference getSarlCapacityFieldType ( IResolvedTypes resolvedTypes , JvmField field ) { LightweightTypeReference fieldType = resolvedTypes . getActualType ( field ) ; final JvmAnnotationReference capacityAnnotation = this . annotationLookup . findAnnotation ( field , ImportedCapacityFeature . class ) ; if ( capacityAnnotation != null ) { final JvmTypeReference ref = ( ( JvmTypeAnnotationValue ) capacityAnnotation . getValues ( ) . get ( 0 ) ) . getValues ( ) . get ( 0 ) ; fieldType = resolvedTypes . getActualType ( ref . getType ( ) ) ; } return fieldType ; }
Replies the type of the field that represents a SARL capacity buffer .
33,772
protected XAbstractFeatureCall createSarlCapacityExtensionProvider ( JvmIdentifiableElement thisFeature , JvmField field ) { if ( thisFeature instanceof JvmDeclaredType ) { final JvmAnnotationReference capacityAnnotation = this . annotationLookup . findAnnotation ( field , ImportedCapacityFeature . class ) ; if ( capacityAnnotation != null ) { final String methodName = Utils . createNameForHiddenCapacityImplementationCallingMethodFromFieldName ( field . getSimpleName ( ) ) ; final JvmOperation callerOperation = findOperation ( ( JvmDeclaredType ) thisFeature , methodName ) ; if ( callerOperation != null ) { final XbaseFactory baseFactory = getXbaseFactory ( ) ; final XMemberFeatureCall extensionProvider = baseFactory . createXMemberFeatureCall ( ) ; extensionProvider . setFeature ( callerOperation ) ; final XFeatureCall thisAccess = baseFactory . createXFeatureCall ( ) ; thisAccess . setFeature ( thisFeature ) ; extensionProvider . setMemberCallTarget ( thisAccess ) ; return extensionProvider ; } } } return null ; }
Create the extension provider dedicated to the access to the used capacity functions .
33,773
protected static boolean runRejectedTask ( Runnable runnable , ThreadPoolExecutor executor ) { if ( ! executor . isShutdown ( ) ) { runnable . run ( ) ; return true ; } return false ; }
Run the given task within the current thread if the executor is not shut down . The task is not run by the given executor . The executor is used for checking if the executor service is shut down .
33,774
public static < C extends Capacity > C createSkillDelegator ( Skill originalSkill , Class < C > capacity , AgentTrait capacityCaller ) throws Exception { final String name = capacity . getName ( ) + CAPACITY_WRAPPER_NAME ; final Class < ? > type = Class . forName ( name , true , capacity . getClassLoader ( ) ) ; final Constructor < ? > cons = type . getDeclaredConstructor ( capacity , AgentTrait . class ) ; return capacity . cast ( cons . newInstance ( originalSkill , capacityCaller ) ) ; }
Create a delegator for the given skill .
33,775
public static < C extends Capacity > C createSkillDelegatorIfPossible ( Skill originalSkill , Class < C > capacity , AgentTrait capacityCaller ) throws ClassCastException { try { return Capacities . createSkillDelegator ( originalSkill , capacity , capacityCaller ) ; } catch ( Exception e ) { return capacity . cast ( originalSkill ) ; } }
Create a delegator for the given skill when it is possible .
33,776
protected void build ( EObject object , ISourceAppender appender ) throws IOException { final IJvmTypeProvider provider = getTypeResolutionContext ( ) ; if ( provider != null ) { final Map < Key < ? > , Binding < ? > > bindings = this . originalInjector . getBindings ( ) ; Injector localInjector = CodeBuilderFactory . createOverridingInjector ( this . originalInjector , ( binder ) -> binder . bind ( AbstractTypeScopeProvider . class ) . toInstance ( AbstractSourceAppender . this . scopeProvider ) ) ; final IScopeProvider oldDelegate = this . typeScopes . getDelegate ( ) ; localInjector . injectMembers ( this . typeScopes ) ; try { final AppenderSerializer serializer = localInjector . getProvider ( AppenderSerializer . class ) . get ( ) ; serializer . serialize ( object , appender , isFormatting ( ) ) ; } finally { try { final Field f = DelegatingScopes . class . getDeclaredField ( "delegate" ) ; if ( ! f . isAccessible ( ) ) { f . setAccessible ( true ) ; } f . set ( this . typeScopes , oldDelegate ) ; } catch ( Exception exception ) { throw new Error ( exception ) ; } } } else { final AppenderSerializer serializer = this . originalInjector . getProvider ( AppenderSerializer . class ) . get ( ) ; serializer . serialize ( object , appender , isFormatting ( ) ) ; } }
Build the source code and put it into the given appender .
33,777
protected boolean isEarlyExitSARLStatement ( XExpression expression ) { if ( expression instanceof XAbstractFeatureCall ) { final Object element = expression . eGet ( XbasePackage . Literals . XABSTRACT_FEATURE_CALL__FEATURE , false ) ; return this . originalComputer . isEarlyExitAnnotatedElement ( element ) ; } return false ; }
Replies if the given expression is a early - exit SARL statement .
33,778
public void addUpperConstraint ( String type ) { final JvmUpperBound constraint = this . jvmTypesFactory . createJvmUpperBound ( ) ; constraint . setTypeReference ( newTypeRef ( this . context , type ) ) ; getJvmTypeParameter ( ) . getConstraints ( ) . add ( constraint ) ; }
Add upper type bounds .
33,779
public void addLowerConstraint ( String type ) { final JvmLowerBound constraint = this . jvmTypesFactory . createJvmLowerBound ( ) ; constraint . setTypeReference ( newTypeRef ( this . context , type ) ) ; getJvmTypeParameter ( ) . getConstraints ( ) . add ( constraint ) ; }
Add lower type bounds .
33,780
public ImageDescriptor getImageDescriptor ( String imagePath ) { ImageDescriptor descriptor = getImageRegistry ( ) . getDescriptor ( imagePath ) ; if ( descriptor == null ) { descriptor = AbstractUIPlugin . imageDescriptorFromPlugin ( SARLEclipsePlugin . PLUGIN_ID , imagePath ) ; if ( descriptor != null ) { getImageRegistry ( ) . put ( imagePath , descriptor ) ; } } return descriptor ; }
Replies the image descriptor for the given image path .
33,781
@ SuppressWarnings ( "static-method" ) public IStatus createMultiStatus ( Iterable < ? extends IStatus > status ) { final IStatus max = findMax ( status ) ; final MultiStatus multiStatus ; if ( max == null ) { multiStatus = new MultiStatus ( PLUGIN_ID , 0 , null , null ) ; } else { multiStatus = new MultiStatus ( PLUGIN_ID , 0 , max . getMessage ( ) , max . getException ( ) ) ; } for ( final IStatus s : status ) { multiStatus . add ( s ) ; } return multiStatus ; }
Create a multistatus .
33,782
public void logErrorMessage ( String message ) { getILog ( ) . log ( new Status ( IStatus . ERROR , PLUGIN_ID , message , null ) ) ; }
Logs an internal error with the specified message .
33,783
@ SuppressWarnings ( { "static-method" , "checkstyle:regexp" } ) public void logDebugMessage ( String message , Throwable cause ) { Debug . println ( message ) ; if ( cause != null ) { Debug . printStackTrace ( cause ) ; } }
Logs an internal debug message with the specified message .
33,784
public void savePreferences ( ) { final IEclipsePreferences prefs = getPreferences ( ) ; try { prefs . flush ( ) ; } catch ( BackingStoreException e ) { getILog ( ) . log ( createStatus ( IStatus . ERROR , e ) ) ; } }
Saves the preferences for the plug - in .
33,785
public void openError ( Shell shell , String title , String message , Throwable exception ) { final Throwable ex = ( exception != null ) ? Throwables . getRootCause ( exception ) : null ; if ( ex != null ) { log ( ex ) ; final IStatus status = createStatus ( IStatus . ERROR , message , ex ) ; ErrorDialog . openError ( shell , title , message , status ) ; } else { MessageDialog . openError ( shell , title , message ) ; } }
Display an error dialog and log the error .
33,786
public static IJavaSearchScope createSearchScope ( IJavaProject project , Class < ? > type , boolean onlySubTypes ) { try { final IType superType = project . findType ( type . getName ( ) ) ; return SearchEngine . createStrictHierarchyScope ( project , superType , onlySubTypes , true , null ) ; } catch ( JavaModelException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } return SearchEngine . createJavaSearchScope ( new IJavaElement [ ] { project } ) ; }
Creates a searching scope including only one project .
33,787
private void fillWizardPageWithSelectedTypes ( ) { final StructuredSelection selection = getSelectedItems ( ) ; if ( selection == null ) { return ; } for ( final Iterator < ? > iter = selection . iterator ( ) ; iter . hasNext ( ) ; ) { final Object obj = iter . next ( ) ; if ( obj instanceof TypeNameMatch ) { accessedHistoryItem ( obj ) ; final TypeNameMatch type = ( TypeNameMatch ) obj ; final String qualifiedName = Utilities . getNameWithTypeParameters ( type . getType ( ) ) ; final String message ; if ( addTypeToWizardPage ( this . typeWizardPage , qualifiedName ) ) { message = MessageFormat . format ( Messages . AbstractSuperTypeSelectionDialog_2 , TextProcessor . process ( qualifiedName , JAVA_ELEMENT_DELIMITERS ) ) ; } else { message = MessageFormat . format ( Messages . AbstractSuperTypeSelectionDialog_3 , TextProcessor . process ( qualifiedName , JAVA_ELEMENT_DELIMITERS ) ) ; } updateStatus ( new StatusInfo ( IStatus . INFO , message ) ) ; } } }
Adds selected interfaces to the list .
33,788
protected IScope createCastOperatorScope ( EObject context , EReference reference , IResolvedTypes resolvedTypes ) { if ( ! ( context instanceof SarlCastedExpression ) ) { return IScope . NULLSCOPE ; } final SarlCastedExpression call = ( SarlCastedExpression ) context ; final XExpression receiver = call . getTarget ( ) ; if ( receiver == null ) { return IScope . NULLSCOPE ; } return getFeatureScopes ( ) . createFeatureCallScopeForReceiver ( call , receiver , getParent ( ) , resolvedTypes ) ; }
create a scope for cast operator .
33,789
public void eInit ( IJvmTypeProvider context ) { setTypeResolutionContext ( context ) ; if ( this . block == null ) { this . block = XbaseFactory . eINSTANCE . createXBlockExpression ( ) ; } }
Create the XBlockExpression .
33,790
public String getAutoGeneratedActionString ( Resource resource ) { TaskTags tags = getTaskTagProvider ( ) . getTaskTags ( resource ) ; String taskTag ; if ( tags != null && tags . getTaskTags ( ) != null && ! tags . getTaskTags ( ) . isEmpty ( ) ) { taskTag = tags . getTaskTags ( ) . get ( 0 ) . getName ( ) ; } else { taskTag = "TODO" ; } return taskTag + " Auto-generated code." ; }
Replies the string for auto - generated comments .
33,791
public IExpressionBuilder addExpression ( ) { final IExpressionBuilder builder = this . expressionProvider . get ( ) ; builder . eInit ( getXBlockExpression ( ) , new Procedures . Procedure1 < XExpression > ( ) { private int index = - 1 ; public void apply ( XExpression it ) { if ( this . index >= 0 ) { getXBlockExpression ( ) . getExpressions ( ) . set ( index , it ) ; } else { getXBlockExpression ( ) . getExpressions ( ) . add ( it ) ; this . index = getXBlockExpression ( ) . getExpressions ( ) . size ( ) - 1 ; } } } , getTypeResolutionContext ( ) ) ; return builder ; }
Add an expression inside the block .
33,792
private void handleAntScriptBrowseButtonPressed ( ) { FileDialog dialog = new FileDialog ( getContainer ( ) . getShell ( ) , SWT . SAVE ) ; dialog . setFilterExtensions ( new String [ ] { "*." + ANTSCRIPT_EXTENSION } ) ; String currentSourceString = getAntScriptValue ( ) ; int lastSeparatorIndex = currentSourceString . lastIndexOf ( File . separator ) ; if ( lastSeparatorIndex != - 1 ) { dialog . setFilterPath ( currentSourceString . substring ( 0 , lastSeparatorIndex ) ) ; dialog . setFileName ( currentSourceString . substring ( lastSeparatorIndex + 1 , currentSourceString . length ( ) ) ) ; } String selectedFileName = dialog . open ( ) ; if ( selectedFileName != null ) fAntScriptNamesCombo . setText ( selectedFileName ) ; }
Open an appropriate ant script browser so that the user can specify a source to import from
33,793
private String getAntScriptValue ( ) { String antScriptText = fAntScriptNamesCombo . getText ( ) . trim ( ) ; if ( antScriptText . indexOf ( '.' ) < 0 ) antScriptText += "." + ANTSCRIPT_EXTENSION ; return antScriptText ; }
Answer the contents of the ant script specification widget . If this value does not have the required suffix then add it first .
33,794
protected Label createLabel ( Composite parent , String text , boolean bold ) { Label label = new Label ( parent , SWT . NONE ) ; if ( bold ) label . setFont ( JFaceResources . getBannerFont ( ) ) ; label . setText ( text ) ; GridData gridData = new GridData ( SWT . BEGINNING , SWT . CENTER , false , false ) ; label . setLayoutData ( gridData ) ; return label ; }
Creates a new label with an optional bold font .
33,795
protected void createLibraryHandlingGroup ( Composite parent ) { fLibraryHandlingGroup = new Composite ( parent , SWT . NONE ) ; GridLayout layout = new GridLayout ( ) ; fLibraryHandlingGroup . setLayout ( layout ) ; fLibraryHandlingGroup . setLayoutData ( new GridData ( GridData . HORIZONTAL_ALIGN_FILL | GridData . VERTICAL_ALIGN_FILL | GridData . GRAB_HORIZONTAL ) ) ; createLabel ( fLibraryHandlingGroup , FatJarPackagerMessages . FatJarPackageWizardPage_libraryHandlingGroupTitle , false ) ; fExtractJarsRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fExtractJarsRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_extractJars_text ) ; fExtractJarsRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fExtractJarsRadioButton . addListener ( SWT . Selection , new Listener ( ) { public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new ExtractLibraryHandler ( ) ; } } ) ; fPackageJarsRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fPackageJarsRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_packageJars_text ) ; fPackageJarsRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fPackageJarsRadioButton . addListener ( SWT . Selection , new Listener ( ) { public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new PackageLibraryHandler ( ) ; } } ) ; fCopyJarFilesRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fCopyJarFilesRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_copyJarFiles_text ) ; fCopyJarFilesRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fCopyJarFilesRadioButton . addListener ( SWT . Selection , new Listener ( ) { public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new CopyLibraryHandler ( ) ; } } ) ; setLibraryHandler ( new ExtractLibraryHandler ( ) ) ; }
Create the export options specification widgets .
33,796
protected void updateModel ( ) { super . updateModel ( ) ; String comboText = fAntScriptNamesCombo . getText ( ) ; IPath path = Path . fromOSString ( comboText ) ; if ( path . segmentCount ( ) > 0 && ensureAntScriptFileIsValid ( path . toFile ( ) ) && path . getFileExtension ( ) == null ) path = path . addFileExtension ( ANTSCRIPT_EXTENSION ) ; fAntScriptLocation = getAbsoluteLocation ( path ) ; }
Stores the widget values in the JAR package .
33,797
private IPath getAbsoluteLocation ( IPath location ) { if ( location . isAbsolute ( ) ) return location ; IWorkspaceRoot root = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; if ( location . segmentCount ( ) >= 2 && ! ".." . equals ( location . segment ( 0 ) ) ) { IFile file = root . getFile ( location ) ; IPath absolutePath = file . getLocation ( ) ; if ( absolutePath != null ) { return absolutePath ; } } return root . getLocation ( ) . append ( location ) ; }
Gets the absolute location relative to the workspace .
33,798
private boolean ensureAntScriptFileIsValid ( File antScriptFile ) { if ( antScriptFile . exists ( ) && antScriptFile . isDirectory ( ) && fAntScriptNamesCombo . getText ( ) . length ( ) > 0 ) { setErrorMessage ( FatJarPackagerMessages . FatJarPackageWizardPage_error_antScriptLocationIsDir ) ; fAntScriptNamesCombo . setFocus ( ) ; return false ; } if ( antScriptFile . exists ( ) ) { if ( ! antScriptFile . canWrite ( ) ) { setErrorMessage ( FatJarPackagerMessages . FatJarPackageWizardPage_error_antScriptLocationUnwritable ) ; fAntScriptNamesCombo . setFocus ( ) ; return false ; } } return true ; }
Returns a boolean indicating whether the passed File handle is is valid and available for use .
33,799
protected static String getPathLabel ( IPath path , boolean isOSPath ) { String label ; if ( isOSPath ) { label = path . toOSString ( ) ; } else { label = path . makeRelative ( ) . toString ( ) ; } return label ; }
Returns the label of a path .